jcabanillas/yii2-blog

适用于其他应用的Yii2 Blog

安装次数: 44

依赖项: 0

建议者: 0

安全: 0

星标: 0

关注者: 1

分支: 0

开放问题: 0

类型:yii2-extension

dev-master 2017-06-05 19:25 UTC

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 &copy; ' . 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
];

访问URL

  1. 后端: http://you-domain/backend/web/blog
  2. 前端: http://you-domain/fontend/web/blog