yii2-plugins-system

Yii2 plugins system module with event manager and https://github.com/loveorigami/yii2-shortcodes-pack

Github星跟蹤圖

Getting started with Yii2-plugins-system

Latest Stable Version
Total Downloads
License

Yii2-plugins-system is designed to work out of the box. It means that installation requires
minimal steps. Only one configuration step should be taken and you are ready to
have plugin system on your Yii2 website.

"Plugins"

1. Download

Yii2-plugins-system can be installed using composer. Run following command to download and
install Yii2-plugins-system:

composer require "loveorigami/yii2-plugins-system": ">=3.*"

2. Update database schema

The last thing you need to do is updating your database schema by applying the
migrations. Make sure that you have properly configured db application component,
add in our console config namespace migration - more here

return [
    'controllerMap' => [
        'migrate' => [
            'class' => 'yii\console\controllers\MigrateController',
            'migrationNamespaces' => [
                 ...
                'lo\plugins\migrations'
            ],
        ],
    ],
];

and run the following command:

$ php yii migrate

3. Configure application

Let's start with defining module in @backend/config/main.php:

'modules' => [
    'plugins' => [
        'class' => 'lo\plugins\Module',
        'pluginsDir'=>[
            '@lo/plugins/core', // default dir with core plugins
            // '@common/plugins', // dir with our plugins
        ]
    ],
],

That's all, now you have module installed and configured in advanced template.

Next, open @frontend/config/main.php and add following:

...
'bootstrap' => ['log', 'plugins'],
...
'components' => [
    'plugins' => [
        'class' => lo\plugins\components\PluginsManager::class,
        'appId' => 1 // lo\plugins\BasePlugin::APP_FRONTEND,
        // by default
        'enablePlugins' => true,
        'shortcodesParse' => true,
        'shortcodesIgnoreBlocks' => [
            '<pre[^>]*>' => '<\/pre>',
            //'<div class="content[^>]*>' => '<\/div>',
        ]
    ],
    'view' => [
        'class' => lo\plugins\components\View::class,
    ]
    ...
]

Also do the same thing with

  • @backend/config/main.php
  • @console/config/main.php
  • @api/config/main.php
  • our modules
  • etc...
...
'bootstrap' => ['log', 'plugins'],
...
'components' => [
    'plugins' => [
        'class' => lo\plugins\components\PluginsManager::class,
        'appId' => 2 // lo\plugins\BasePlugin::APP_BACKEND or our appId
    ],
    'view' => [
        'class' => lo\plugins\components\View::class,
    ]
    ...
]

Base AppId lo\plugins\BasePlugin::

  • const APP_FRONTEND = 1;
  • const APP_BACKEND = 2;
  • const APP_COMMON = 3;
  • const APP_API = 4;
  • const APP_CONSOLE = 5;

Shortcodes

Core plugins (examples)

Your plugins

Contributing to this project

Anyone and everyone is welcome to contribute. Please take a moment to
review the guidelines for contributing.

License

Yii2-plugins-system is released under the MIT License. See the bundled LICENSE.md
for details.

主要指標

概覽
名稱與所有者loveorigami/yii2-plugins-system
主編程語言PHP
編程語言PHP (語言數: 1)
平台
許可證MIT License
所有者活动
創建於2015-08-02 15:39:20
推送於2019-03-12 11:10:42
最后一次提交2019-03-12 14:10:40
發布數10
最新版本名稱3.1.5 (發布於 )
第一版名稱1.0-rc (發布於 2015-08-02 19:18:33)
用户参与
星數115
關注者數19
派生數23
提交數145
已啟用問題?
問題數21
打開的問題數0
拉請求數0
打開的拉請求數0
關閉的拉請求數0
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?