funson86 / yii2-blog
适用于其他应用的 Yii2 Blog
dev-master
2015-08-07 03:54 UTC
Requires
This package is not auto-updated.
Last update: 2024-09-24 03:04:38 UTC
README
适用于其他应用的 Yii2 Blog,特别是适用于 Yii2 Adminlte
安装
推荐通过 composer 安装此扩展。
运行以下命令之一
php composer.phar require --prefer-dist funson86/yii2-blog "dev-master"
或将以下内容添加到您的 composer.json
文件的 require 部分中。
"funson86/yii2-blog": "*"
迁移
运行迁移
yii migrate --migrationPath=@funson86/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' => 'funson86\blog\Module', 'controllerNamespace' => 'funson86\blog\controllers\backend' ], ],
在前端/config/main.php 中配置前端模块
'defaultRoute' => 'blog', //set blog as default route 'modules' => [ 'blog' => [ 'class' => 'funson86\blog\Module', 'controllerNamespace' => 'funson86\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', 'Funson86 Blog' => 'http://github.com/funson86/yii2-blog', ], 'blogUploadPath' => 'upload/', //default to frontend/web/upload ];