jcabanillas / yii2-blog
适用于其他应用的Yii2 Blog
dev-master
2017-06-05 19:25 UTC
Requires
This package is auto-updated.
Last update: 2024-09-08 05:32:04 UTC
README
适用于其他应用的Yii2 Blog,尤其是适用于Yii2 Adminlte
安装
安装此扩展的首选方式是通过composer。
运行以下命令之一:
php composer.phar require --prefer-dist jcabanillas/yii2-blog "dev-master"
或者在您的composer.json
文件的require部分添加:
"jcabanillas/yii2-blog": "*"
迁移
运行迁移
yii migrate --migrationPath=@jcabanillas/blog/migrations
在/common/config/main.php中配置url重写
'timeZone' => 'Asia/Shanghai', //time zone affect the formatter datetime format 'components' => [ 'urlManager' => [ 'enablePrettyUrl' => true, 'showScriptName' => false, 'rules' => [ '<controller:\w+>/<id:\d+>' => '<controller>/view', '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>', '<controller:\w+>/<action:\w+>' => '<controller>/<action>', ], ], 'formatter' => [ //for the showing of date datetime 'dateFormat' => 'yyyy-MM-dd', 'datetimeFormat' => 'yyyy-MM-dd HH:mm:ss', 'decimalSeparator' => ',', 'thousandSeparator' => ' ', 'currencyCode' => 'CNY', ], ],
在backend/config/main.php中配置后端模块
'modules' => [ 'blog' => [ 'class' => 'jcabanillas\blog\Module', 'controllerNamespace' => 'jcabanillas\blog\controllers\backend' ], ],
在前端/config/main.php中配置前端模块
'defaultRoute' => 'blog', //set blog as default route 'modules' => [ 'blog' => [ 'class' => 'jcabanillas\blog\Module', 'controllerNamespace' => 'jcabanillas\blog\controllers\frontend' ], ],
在/common/config/params.php中添加yii2-blog参数。
return [ 'blogTitle' => 'HikeBlog', 'blogTitleSeo' => 'Simple Blog based on Yii2', 'blogFooter' => 'Copyright © ' . date('Y') . ' by ahuasheng on Yii2. All Rights Reserved.', 'blogPostPageCount' => '10', 'blogLinks' => [ 'Google' => 'http://www.google.com', 'jcabanillas Blog' => 'http://github.com/jcabanillas/yii2-blog', ], 'blogUploadPath' => 'upload/', //default to frontend/web/upload ];