tadasshi/yii2-responsive-blog

适用于其他应用的 Yii2 博客

安装: 7

依赖项: 0

建议者: 0

安全: 0

星标: 1

关注者: 2

分支: 0

开放问题: 0

类型:yii2-extension

dev-master 2015-11-27 18:16 UTC

This package is not auto-updated.

Last update: 2024-09-18 18:31:09 UTC


README

适用于其他应用的 Yii2 博客,尤其是针对 Yii2 Adminlte

安装

首选安装此扩展的方式是通过 composer

运行

php composer.phar require --prefer-dist funson86/yii2-blog "dev-master"

或添加

"funson86/yii2-blog": "*"

到你的 composer.json 文件的 require 部分中。

迁移

运行迁移

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

访问 URL

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