dhluther / yii2-swivel
一个 Yii 2.0 插件,提供轻松访问和集成 zumba/swivel 的功能
3.0.1
2023-12-22 17:07 UTC
Requires
- php: ~8.0.0|~8.1.0|~8.2.0|~8.3.0
- psr/log: ^1.0.0 | ^2.0 | ^3.0
- yiisoft/yii2: ~2.0.40
- zumba/swivel: ^4.0
README
此插件为在 Yii 2.0+ 应用中使用 Swivel 提供必要的元素。
此插件基于 zumba/swivel-cake 插件。
Yii 组件配置
'swivel' => [ 'class'=>'dhluther\swivel\SwivelComponent' ],
从应用中访问
// If the user has the feature behavior bucket enabled, use the testFeature.New.Something behavior, // else use the default Yii::$app->swivel->forFeature( 'testFeature' ) ->addBehavior('New.Something', [$this,'doSomethingB'], $args) ->defaultBehavior([$this, 'doSomethingA'], $args ) ->execute(); // If the user has the feature behavior bucket enabled, use the first callable, // else use the second callable (default) Yii::$app->swivel->invoke('testFeature.New.Something', [$this,'doSomethingB'],[$this, 'doSomethingA']);
确保您的 bootstrap 文件已正确设置以包含 composer 自动加载器。
在 index.php 的 bootstrap 中
require(__DIR__ . '/../vendor/autoload.php');
将 swivel 迁移命名空间添加到您的迁移命令配置中
'migrationNamespaces'=>[ 'dhluther\\swivel\\migrations' ]
并使用以下别名
'@dhluther\swivel'=>'@vendor/dhluther/yii2-swivel/src'
如果您以前已迁移此包并想通过命名空间标记为当前迁移,命令为
./yii migrate/mark dhluther\\swivel\\migrations\\m190812_083802
添加 composer 供应商库以进行本地开发
docker run --rm -v $PWD:/app composer update