sergmoro1/yii2-blog-tools

博客工具。帖子、作者、用户、标签、分类、评论后端SBAdmin-panel管理。

安装: 191

依赖: 1

建议者: 0

安全: 0

星标: 0

关注者: 3

分支: 0

开放问题: 0

类型:yii2-extension

v1.1.11 2019-11-29 17:00 UTC

This package is auto-updated.

Last update: 2024-09-04 09:20:37 UTC


README

普通帖子管理系统。可作为任何应用的基座。

优势

  • 帖子、嵌套集合分类、标签、用户、作者;
  • 评论管理、更新、回复;
  • Imperavi redactor;
  • 文件和图片上传、照片链式循环轮播图;
  • 通过电子邮件确认或通过网络账号进行用户注册;
  • RBAC。

安装

  1. 安装包

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

运行以下命令之一:

composer require --prefer-dist sergmoro1/yii2-blog-tools

或者在您的composer.json文件的要求部分添加:

"sergmoro1/yii2-blog-tools": "^1.1"

  1. Git初始化

git init

  1. 配置迁移

使用namespace将迁移文件夹的信息添加到console\config\main.php中的controllerMap部分。

    'controllerMap' => [
        'migrate' => [
            'class' => 'yii\console\controllers\MigrateController',
            'migrationNamespaces' => [
                'sergmoro1\uploader\migrations',
                'sergmoro1\lookup\migrations',
                'sergmoro1\user\migrations',
                'sergmoro1\blog\migrations',
                'sergmoro1\comment\migrations',
            ],
        ],
    ],
  1. 运行迁移
php yii migrate
php yii migrate --migrationPath=@vendor/notgosu/yii2-meta-tag-module/src/migrations
  1. 初始化博客

通过批处理文件initblog将预定义文件批量复制到相应的文件夹。

要获取它,在应用目录下执行命令。

cp ./vendor/sergmoro1/yii2-blog-tools/src/initblog ./

然后运行批处理文件。

php initblog

将文件夹设置为可写以存储上传的文件。

chmod -R 777 ./frontend/web/files

配置

backend/config/main.php中进行设置。

return [
    'defaultRoute' => '/blog/site/index',
    'layoutPath' => '@vendor/sergmoro1/yii2-blog-tools/src/views/layouts',
    'modules' => [
        'uploader' => ['class' => 'sergmoro1\uploader\Module'],
    ],
    'components' => [
        'authManager' => [
            'class' => 'yii\rbac\PhpManager',
            'defaultRoles' => ['commentator', 'author', 'admin'],
            'itemFile' => __DIR__ . '/../../console/rbac/items.php',
            'ruleFile' => __DIR__ . '/../../console/rbac/rules.php',
        ],
        'user' => [
            'class' => 'yii\web\User',
            'identityClass' => 'common\models\User',
            'enableAutoLogin' => true,
            'identityCookie' => ['name' => '_identity-backend', 'httpOnly' => true],
        ],
        'urlManager' => [
            'class' => 'yii\web\UrlManager',
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'enableStrictParsing' => false,
        ],
        'errorHandler' => [
            'errorAction' => '/blog/site/error',
        ],
    ],
];

common/config/main.php中进行设置。

return [
    'language' => 'ru-RU', // 'en-US',
    'bootstrap' => [
        'blog',
        'comment',
    ],
    'modules' => [
        'lookup'        => ['class' => 'sergmoro1\lookup\Module'],
        'blog'          => ['class' => 'sergmoro1\blog\Module'],
        'comment'       => ['class' => 'sergmoro1\comment\Module'],
        'user'          => ['class' => 'sergmoro1\user\Module'],
        'seo'           => ['class' => 'notgosu\yii2\modules\metaTag\Module'],
    ],
    'components' => [
        'authManager' => [
            'class' => 'yii\rbac\PhpManager',
        ],
        'user' => [
            'class' => 'yii\web\User',
        ],
        'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            'useFileTransport' => false,
            'viewPath' => '@vendor/sergmoro1/yii2-user/src/mail',
            /* Definition of Yandex post office for your domain (example).
            'transport' => [
                'class' => 'Swift_SmtpTransport',
                'host' => 'smtp.yandex.ru',
                'username' => 'admin@your-site.ru',
                'password' => 'your-password',
                'port' => '465',
                'encryption' => 'ssl',
            ],
            */
        ],
        'i18n' => [
            'translations' => [
                'app*' => [
                    'class' => 'yii\i18n\PhpMessageSource',
                    'basePath' => '@app/../messages',
                    'sourceLanguage' => 'en-US',
                    'fileMap' => [
                        'app' => 'app.php',
                        'app/error' => 'error.php',
                    ],
                ],
                'metaTag' => [
                    'class' => 'yii\i18n\PhpMessageSource',
                ],
                // sergmoro1/user/models/LoginForm is used in frontend/controllers/SiteController, so
                // it is not used within the Module then translation should be defined twice
                // here and in a sergmoro1/user/Module::registerTranslations()
                'sergmoro1/user/*' => [
                    'class' => 'yii\i18n\PhpMessageSource',
                    'sourceLanguage' => 'en-US',
                    'basePath' => '@vendor/sergmoro1/yii2-user/src/messages',
                    'fileMap' => [
                        'sergmoro1/user/core' => 'core.php',
                    ],
                ],
            ],
        ],
    ],
];

common/config/params-local.php中进行设置。

return [
    // localhost or real host
    'frontend' => 'https://',
];

不要忘记将.htaccess文件添加到backend/webfrontend/web

启动

进入http://your-app/backend/web登录

名称: Admin

密码: 123456