teqneers/ext-application

将 Sencha Ext JS 集成到 PHP 应用程序的基础组件

3.0.1 2022-07-25 08:21 UTC

This package is auto-updated.

Last update: 2024-08-25 12:34:05 UTC


README

将 Sencha Ext JS 集成到 PHP 应用程序的基础组件

Build Status

简介

此库围绕从开发和生产环境中运行 Sencha Ext JS 6(尽管 5 也应该可以工作)应用的不同需求提供了一个简单的抽象。开发和生产构建使用不同的源树来提供应用程序文件。此过程基于所谓的 清单和 JavaScript 微加载器。为了确保此过程与服务器生成的页面和路由无缝工作,库挂钩到清单生成并动态修改清单,基于所需的环境和上下文。

目前,此库仅用作 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 \TQ\ExtJS\Application\Manifest\Manifest configured correctly when running document root on your application base path

echo $manifest; // outputs the manifest

在开发模式下运行应用程序时,您必须确保您的 Web 服务器文档根位于(常规)公共 Web 面向目录的上一个级别,以便 Web 服务器可以提供 Ext JS 应用程序工作区的文件。

许可证

MIT 许可证 (MIT)

版权所有 © 2021 TEQneers GmbH & Co. KG

在此,免费授予任何获得本软件及其相关文档文件(“软件”)副本的人(“许可人”)无限制地处理软件的权利,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或销售软件副本,并允许向软件提供的人这样做,前提是遵守以下条件

上述版权声明和本许可声明应包含在软件的所有副本或实质性部分中。

本软件按“原样”提供,不提供任何明示或暗示的保证,包括但不限于适销性、特定用途适用性和非侵权性保证。在任何情况下,作者或版权所有者均不对任何索赔、损害或其他责任承担责任,无论此类责任是基于合同、侵权或其他方式,无论此类责任是否因软件或软件的使用或其他方式产生、存在或与之相关。