yongtiger/yii2-application

1.1.0 2017-03-15 00:32 UTC

This package is not auto-updated.

Last update: 2024-09-28 20:40:51 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License

特性

  • 应用中的beforeInit()afterInit()
  • 远程应用程序回调,例如从后端调用前端缓存清理

依赖关系

安装

通过composer安装此扩展是首选方法,请访问composer下载。

运行以下命令

php composer.phar require --prefer-dist yongtiger/yii2-application "*"

或将以下代码添加到composer.json的require部分

"yongtiger/yii2-application": "*"

配置

  • \common\config\params.php
'yongtiger.application.remoteAppConfigs' => [
    'app-backend' => [
        'class' => 'backend\\components\\Application',	///optional
        '@common/config/main.php',
        '@common/config/main-local.php',
        '@backend/config/main.php',
        '@backend/config/main-local.php',
    ],
    'app-frontend' => [
        'class' => 'frontend\\components\\Application',	///optional
        '@common/config/main.php',
        '@common/config/main-local.php',
        '@frontend/config/main.php',
        '@frontend/config/main-local.php',
    ],
],

用法

  • beforeInit()afterInit()
class Application extends \yongtiger\application\Application 
{
    /**
     * @inheritdoc
     */
    public function beforeInit() {
        
        parent::beforeInit();

        ///[v0.10.5 (filter theme bootstrap)]
        ///You can still run without yii2 extension `yongtiger/yii-theme`.
        ///Note: Cannot use `class_exists('yongtiger\\theme\\Bootstrap')` before application init!
        if (is_file($this->getVendorPath() . DIRECTORY_SEPARATOR . 'yongtiger'. DIRECTORY_SEPARATOR . 'yii2-theme' . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'Bootstrap.php')) {

            \yongtiger\theme\Bootstrap::filterExtensionsBootstrap();

        }
        
    }

    /**
     * @inheritdoc
     */
    public function afterInit() {
        
        parent::afterInit();

    }
}
  • 远程应用程序回调
Application::remoteAppCall('app-frontend', function($app) {
    $app->cache->flush();
}, function ($config) {
    unset($config['bootstrap']);    ///[yii2-brainbase v0.3.0 (admin:rbac):fix Yii debug disappear in route]
    return $config;
});

注意

文档

另请参阅

待办事项

开发路线图

许可证

Yii2-application采用MIT许可证发布,有关详细信息,请参阅LICENSE文件。