myzero1 / yii2-z1site
为yii2的简单验证码。只需在配置文件中添加模块,然后使用小部件即可。
1.0.2
2018-11-08 06:42 UTC
Requires
- myzero1/yii2-theme-layui: *
- yiisoft/yii2: ~2.0
This package is not auto-updated.
Last update: 2024-09-20 19:35:14 UTC
README
这是一个用于站点的模块。它会根据条件加载配置文件,并提供网站的一些常见页面。它使用myzero1/yii2-theme-layui作为其主题。
安装
通过以下方式安装此扩展:通过composer。
运行以下命令:
php composer.phar require-dev myzero1/yii2-z1site:*
或者将以下内容添加到您的composer.json
文件的require-dev部分:
"myzero1/yii2-z1site:": "*"
设置
扩展安装后,只需按照以下方式修改您的应用程序配置:
在main.php中
return [ ...... 'basePath' => myzero1\z1site\components\MainLoader::getAppPath(), 'runtimePath' => myzero1\z1site\components\MainLoader::getAppPath() . '/runtime', //basePath,runtimePath,vendorPath,timeZone 'controllerNamespace' => 'myzero1\z1site\controllers', 'bootstrap' => [ 'classMap' => function(){ \Yii::$classMap['yii\captcha\CaptchaAction'] = '@app/components/libs/CaptchaAction.php'; // \Yii::$classMap['myzero1\z1site\controllers\ActController'] = '@vendor/myzero1/yii2-z1site/src/controllers/act/ActController.php'; // \Yii::$classMap['myzero1\z1site\models\LoginForm'] = '@vendor/myzero1/yii2-z1site/src/models/rewrite/LoginForm.php'; } ], 'modules' => [ ...... 'z1siteid' => [ // z1siteid mybe ajust 'class' => 'myzero1\z1site\Module', ], ...... ], 'components' => [ ...... 'errorHandler' => [ 'errorAction' => 'z1siteid/site/error', // z1siteid mybe ajust ], 'urlManager' => [ 'enablePrettyUrl' => true, 'showScriptName' => false, 'rules' => [ '<controller:[\w\-]+>/<action:[\w\-]+>' => 'z1siteid/<controller>/<action>' // z1siteid mybe ajust ], ], 'user' => [ 'identityClass' => 'myzero1\z1site\models\User', 'enableAutoLogin' => true, 'identityCookie' => ['name' => '_identity-backend', 'httpOnly' => true], ], 'view' => [ 'theme' => [ 'pathMap' => [ '@app/views' => '@vendor/myzero1/yii2-theme-layui/src/views', // using the layui theme ], ], ], 'assetManager' => [ 'class' => 'yii\web\AssetManager', 'forceCopy' => true, // 'linkAssets' => true,//link to assets,no cache.used in develop. ], ...... ], ...... ];
使用方法
然后您可以通过访问主页来查看主题。
http://localhost/path/to/index.php
重写
设置重写
return [ ...... 'bootstrap' => [ 'classMap' => function(){ \Yii::$classMap['yii\captcha\CaptchaAction'] = '@app/components/libs/CaptchaAction.php'; \Yii::$classMap['myzero1\z1site\controllers\ActController'] = '@vendor/myzero1/yii2-z1site/src/controllers/act/ActController.php'; \Yii::$classMap['myzero1\z1site\models\LoginForm'] = '@vendor/myzero1/yii2-z1site/src/models/rewrite/LoginForm.php'; } ], ...... ];
重写控制器
通过classMap添加和修改动作。
通过重写控制器的前action重写动作视图。
重写类
您可以通过classMap添加和重写类的功能。
许可协议
MIT