Mac_Yii2_advanced高级版安装总结

Nan (/)
2021-11-03T21:02:00+08:00

以下是我學習yii2.0時的配置方法

1.安装 composer

brew install composer （前提安裝了brew）

2.更改composer鏡像地址

composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/

3.安装 yii2.0_advanced(高级版前后台分离)

cd /你想安装的文件夹
composer create-project --prefer-dist yiisoft/yii2-app-advanced 文件夹名

4.更改權限

sudo chmod -R 777 文件夹名

5.更新yii依賴

composer update

6.初始化環境

到安裝完成的文件夾裏點擊執行 init

7. 修改数据库地址及密码

common/config/main-local.php

<?php


return [
    'components' => [
        'db' => [
            'class' => 'yii\db\Connection',
            'dsn' => 'mysql:host=服务器地址;dbname=数据库名',
            'username' => '用户名',
            'password' => '密码',
            'charset' => 'utf8',
        ],
        'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            'viewPath' => '@common/mail',
            // send all mails to a file by default. You have to set
            // 'useFileTransport' to false and configure a transport
            // for the mailer to send real emails.
            'useFileTransport' => true,
        ],
    ],
];

8.新建數據庫

我用的是phpmyadmin

-- --------------------------------------------------------
CREATE TABLE `user` (
`id` int(10) NOT NULL,
`username` varchar(60) NOT NULL,
`auth_key` char(32) NOT NULL,
`password_hash` char(60) NOT NULL,
`password_rese_token` char(60) DEFAULT NULL,
`verification_token` varchar(60) NOT NULL,
`avatar_path` varchar(140) DEFAULT NULL,
`user_status` tinyint(1) DEFAULT 1,
`created_at` int(10) DEFAULT NULL,
`updated_at` int(10) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

8.配置完畢後可以成功創建用戶但登錄不上？

查看這裏