yeesoft/yii2-yee-core

Yee CMS 核心模块

0.1.2 2020-01-02 16:05 UTC

This package is auto-updated.

Last update: 2022-03-29 00:33:42 UTC


README

Yee CMS 核心模块

安装

安装 yii2-app-advanced 应用程序。

更多信息: 高级应用模板安装.

  1. 使用 Composer 安装
If you do not have [Composer](https://getcomposer.org.cn/), follow the instructions in the
[Installing Yii](https://github.com/yiisoft/yii2/blob/master/docs/guide/start-installation.md#installing-via-composer) section of the definitive guide to install it.

With Composer installed, you can then install the application using the following commands:

```bash
cd /var/www/
composer global require "fxp/composer-asset-plugin:~1.0.0"
composer create-project --prefer-dist yiisoft/yii2-app-advanced mysite.com
```
  1. 初始化已安装的应用程序

    执行 init 命令,并将环境选择为 dev

    cd /var/www/mysite.com/
    php init
  2. 配置您的 Web 服务器

    • 对于 Apache 配置文件可能是以下内容

      <VirtualHost *:80>
        ServerName mysite.com
        ServerAlias www.mysite.com
        DocumentRoot "/var/www/mysite.com/"
        <Directory "/var/www/mysite.com/">
          AllowOverride All
        </Directory>
      </VirtualHost>
    • 在根目录中创建 .htaccess 文件,内容如下

      # prevent directory listings
      Options -Indexes
      RewriteEngine on
      
      RewriteCond %{REQUEST_URI} ^/admin/$
      RewriteRule ^(admin)/$ /$1 [R=301,L]
      RewriteCond %{REQUEST_URI} ^/admin
      RewriteRule ^admin(/.+)?$ /backend/web/$1 [L,PT]
      
      RewriteCond %{REQUEST_URI} ^.*$
      RewriteRule ^(.*)$ /frontend/web/$1
    • backend/web/frontend/web/ 文件夹中创建 .htaccess 文件,内容如下

      RewriteEngine on
      # if a directory or a file exists, use the request directly
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      # otherwise forward the request to index.php
      RewriteRule . index.php
  3. 创建一个新的数据库,并相应地调整 common/config/main-local.php 中的 components['db'] 配置。

  4. 使用控制台命令 php yii migrate 应用迁移。

#####您的 yii2-app-advanced 应用程序已安装。访问您的网站,网站应该可以正常工作,并显示消息 恭喜!您已成功创建您的 Yii 应用程序

更新应用程序配置

  1. 更新 frontend/config/main.php 文件

    添加

    'homeUrl' => '/',

    'components' => [
        'request' => [
            'baseUrl' => '',
        ],
     ]

    'components' => [
        'urlManager' => [
            'class' => 'yii\web\UrlManager',
            'showScriptName' => false,
            'enablePrettyUrl' => true,
            'rules' => array(
                '<module:auth>/<action:\w+>' => '<module>/default/<action>',
                '<action:\w+>' => 'site/<action>',
                '<controller:\w+>/<action:\w+>' => '<controller>/<action>',
            )
        ],
    ]
  2. 更新 backend/config/main.php 文件

    添加

    'homeUrl' => '/admin',

    'components' => [
        'request' => [
            'baseUrl' => '/admin',
        ],
     ]

    'components' => [
        'urlManager' => [
            'class' => 'yii\web\UrlManager',
            'showScriptName' => false,
            'enablePrettyUrl' => true,
            'rules' => array(
                '<module:\w+>/' => '<module>/default/index',
                '<module:\w+>/<action:\w+>/<id:\d+>' => '<module>/default/<action>',
                '<module:\w+>/<action:(create)>' => '<module>/default/<action>',
                '<module:\w+>/<controller:\w+>' => '<module>/<controller>/index',
                '<module:\w+>/<controller:\w+>/<action:\w+>/<id:\d+>' => '<module>/<controller>/<action>',
                '<module:\w+>/<controller:\w+>/<action:\w+>' => '<module>/<controller>/<action>',
                '<controller:\w+>/<id:\d+>' => '<controller>/view',
                '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>',
                '<controller:\w+>/<action:\w+>' => '<controller>/<action>',
            )
        ],
    ]
  3. minimum-stability 设置为 dev,并在 /var/www/mysite.com/composer.json 中添加 "prefer-stable": true

安装 Yee CMS 核心模块

  1. 安装 yeesoft/yii2-yee-core 模块

    • 运行此命令

      composer require --prefer-dist yeesoft/yii2-yee-core "*"
    • 应用迁移

      yii migrate --migrationPath=@vendor/yeesoft/yii2-yee-core/migrations/
    • frontend/config/main.phpbackend/config/main.php 配置中删除 ['components']['user'] 设置。

    • common/config/main.php 中添加 ['components']['user']['modules']['yee'] 设置。

      'components' => [
          'user' => [
              'class' => 'yeesoft\components\User',
              'on afterLogin' => function($event) {
                 \yeesoft\models\UserVisitLog::newVisitor($event->identity->id);
              }
          ],
      ]
      'modules' => [
          'yee' => [
              'class' => 'yeesoft\Yee',
          ],
      ],
  2. ['components']['request']['cookieValidationKey']frontend/config/main-local.phpbackend/config/main-local.php 中的值设置为相同。这对于基于 cookie 的登录的正确工作至关重要。

  3. common/config/main-local.php 中配置您的邮件发送器 ['components']['mailer']

  4. 更新后端控制器

    • backend/controllers/SiteController.php 的内容替换为以下内容
      namespace backend\controllers;
      
      use yeesoft\controllers\admin\BaseController;
      
      class SiteController extends BaseController
      {
          public function actionIndex()
          {
              return $this->render('index');
          }
      }

#####Yee CMS 核心模块已安装!现在您可以在网站上注册。注册后,您可以在 user 表中将 superadmin 字段设置为 1 以启用用户的超级管理员权限。现在登录到网站并访问 http://yoursite.com/admin,应该显示空的控制面板。您可以创建自己的 Yee 模块或安装现有的模块以扩展 Yee CMS 的功能。

安装 Yee CMS 模块

  1. 安装 Yee Auth 模块
  2. 安装 Yee Settings 模块
  3. 安装 Yee Menu 模块
  4. 安装 Yee User 模块
  5. 安装 Yee Media 模块
  6. 安装 Yee Post 模块
  7. 安装 Yee 页面模块
  8. 安装 评论模块
  9. 安装 Yee 评论模块
  10. 安装 Yee 的 Gii 代码生成器