issei / multiple-apps-support

dev-master 2013-07-16 22:17 UTC

This package is auto-updated.

Last update: 2024-09-05 08:29:35 UTC


README

辅助运行多个应用程序的 Symfony2 Standard Edition 项目(详情请见此处)的命令执行。
例如,可以在所有应用程序上依次执行 cache:clear 等命令。

用法

使用 Composer 安装。

$ php composer.phar require issei/multiple-apps-support:dev-master

bin 目录中生成了一个名为 console 的公共控制台。
目前支持 cache:clearassets:installassetic:dump 三种命令。

cache:clear

$ bin/console cache:clear --no-warmup --env=prod
> Excuting command on frontend...
> Clearing the cache for the prod environment with debug false
> Excuting command on api...
> Clearing the cache for the prod environment with debug false

所有操作都使用相同的参数和选项。

assets:install

$ bin/console assets:install --symlink
> Excuting command on frontend...
> Installing assets using the symlink option
> Installing assets for Symfony\Bundle\FrameworkBundle into web/frontend/bundles/framework
> Excuting command on api...
> Installing assets using the symlink option
> Installing assets for Symfony\Bundle\FrameworkBundle into web/api/bundles/framework

第一个参数(默认:web)将附加 /%kernel.name%。选项使用通用设置。
※ 不能使用 -watch--force--perod 选项。

assetic:dump

$ bin/console assetic:install --env=prod --no-debug web
> Excuting command on frontend...
> Dumping all prod assets.
> Debug mode is off.
> 
> xx:xx:xx [file+] $(PROJECT_ROOT)/apps/frontend/../../web/frontend/css/xxxxxx.css
> xx:xx:xx [file+] $(PROJECT_ROOT)/apps/frontend/../../web/frontend/js/xxxxxx.js
> Excuting command on api...
> Dumping all prod assets.
> Debug mode is off.
> 
> xx:xx:xx [file+] $(PROJECT_ROOT)/apps/api/../../web/api/css/xxxxxx.css
> xx:xx:xx [file+] $(PROJECT_ROOT)/apps/api/../../web/api/js/xxxxxx.js

只有当指定了第一个参数(默认:%assetic.write_to%)时,才会附加 /%kernel.name%。选项使用通用设置。

在 Symfony Standard Edition 中运行多个应用程序

PROJECT ROOT
|   
+---apps <------------------------ ここに複数のアプリケーションを格納。
|   |   autoload.php               autoload.php, bootstrap.php.cache 等の共有ファイルはルートに配置。
|   |   bootstrap.php.cache 
|   |   ...
|   |   
|   +---frontend <---------------- アプリケーションルート。ディレクトリ名=アプリケーション名となる。
|   |   |   FrontendCache.php  <-- アプリケーションキャッシュ。
|   |   |   FrontendKernel.php <-- アプリケーションカーネル。クラス名は `Kernel` で終わる必要がある。
|   |   |   console <------------- アプリケーションコンソール
|   |   |   ...
|   |   |   
|   |   +---cache
|   |   +---config 
|   |   +---logs
|   |   \---Resources
|   |               
|   +---api
|   |       ApiCache.php
|   |       ApiKernel.php
|   |       console
|   |       ...
|   |               
|   \---config <------------------ プロジェクト共有のコンフィギュレーション。アプリケーションでimportして使う。
|           config.yml
|           parameters.yml
|           ...
|           
+---bin     
+---src                
\---web
    +---frontend <---------------- アプリケーション公開ディレクトリ。ディレクトリ名はアプリケーションと同様。
    |       .htaccess
    |       app.php
    |       app_dev.php
    |       ...
    |       
    \---api
            ...

将多个应用程序(例如 frontend, api)的内核、配置、缓存等放入以特定应用程序名称命名的目录中,并在 apps 中进行管理。
请将 web 目录中的应用程序,分别按应用程序的目录名称进行嵌套。

※ 请参考以下架构的详细信息。