将 Sencha Ext JS 集成到 PHP 应用程序中的基本组件
该库针对使用服务器生成的页面从开发和生产上下文运行 Sencha Ext JS 6(即使 5 也应该工作)应用程序时的不同要求提供了简单的抽象。开发和生产构建使用不同的源树来提供应用程序文件。这个过程基于所谓的清单和 Javascript 微加载器。为了确保此过程与服务器生成的页面和路由无缝配合,该库挂钩清单生成并根据所需的环境和上下文动态修改清单。
目前,该库仅用作 teqneers/ext-application-bundle 的基础,teqneers/ext-application-bundle 是一个将 Ext JS 集成到基于 Symfony 的应用程序中的 Symfony 包。我们没有尝试将该库用作独立组件或在除 Symfony 环境之外的任何其他上下文中使用,因此以下只是理论上它在没有捆绑包的情况下应该如何工作。我们非常感谢任何帮助和贡献,以使该库在捆绑包之外更有用。
您可以使用composer安装这个库
composer require teqneers/ext-application
或者直接将包添加到您的composer.json 文件中。
给定一个虚构应用程序的以下目录结构
./
|-- src/ Application source code
|-- htdocs/ Public web-facing directory (document root)
| |-- index.php PHP front controller
| |-- app/ Root folder for Ext JS application production build
|-- my-app/ The Ext JS application source folder (sencha generate app -ext MyApp ./my-app)
你应该配置你的应用程序(例如从index.php)
$ config = TQ ExtJS Application Configuration ApplicationConfiguration (
__DIR__ . ' /../my-app ' , // the absolute path to the Ext JS application workspace
' ../my-app ' , // the relative path from the public web-facing directory to the Ext JS application workspace
__DIR__ , // the absolute path to the public web-facing directory
' / ' // the relative path from the public web-facing directory to the root directory used for production build artifacts (usually /)
);
// add a default build
$ config -> addBuild (
' default ' , // the build name (just for referencing the build)
' / ' , // the application path relative to the Ext JS application workspace (usually / unless you have multiple applications and/or packages in a single workspace)
' app ' , // the application path relative to the root directory used for production build artifacts
' manifest.json ' , // the build manifest filename for development builds
' bootstrap.js ' , // the micro-loader filename for development builds
null , // the application cache manifest filename for development builds (usually NULL)
' bootstrap.json ' , // the build manifest filename for production builds
' bootstrap.js ' , // the micro-loader filename for production builds
' cache.appcache ' // the application cache manifest filename fro production builds
);
$ application = new TQ ExtJS Application Application (
$ config ,
new TQ ExtJS Application Manifest ManifestLoader (),
' dev ' // dev or prod depending on wether you want to run from development or drom production build
);
$ microLoader = $ application -> getMicroLoaderFile (); // returns a SplFileInfo for the configured micro-loader
$ hasAppCache = $ application -> hasAppCache ();
if ( $ hasAppCache ) {
$ appCache = $ application -> getAppCacheFile (); // returns a SplFileInfo for the configured application cache manifest
}
$ manifest = $ application -> getManifest ( ' /htdocs ' ); // returns a TQExtJSApplicationManifestManifest configured correctly when running document root on your application base path
echo $ manifest ; // outputs the manifest
在开发模式下运行应用程序时,您必须确保 Web 服务器的文档根目录比(常规)面向公共 Web 的目录高一级,以便 Web 服务器也可以提供来自 Ext JS 应用程序工作区的文件。
麻省理工学院许可证 (MIT)
版权所有 (c) 2021 TEQneers GmbH & Co. KG
特此免费授予获得本软件和相关文档文件(“软件”)副本的任何人不受限制地使用本软件,包括但不限于使用、复制、修改、合并的权利、发布、分发、再许可和/或销售软件的副本,并允许向其提供软件的人员这样做,但须满足以下条件:
上述版权声明和本许可声明应包含在本软件的所有副本或主要部分中。
本软件按“原样”提供,不提供任何明示或暗示的保证,包括但不限于适销性、特定用途的适用性和不侵权的保证。在任何情况下,作者或版权持有者均不对因本软件或本软件中的使用或其他交易而产生或与之相关的任何索赔、损害或其他责任负责,无论是合同、侵权行为还是其他行为。软件。