yii2-advanced框架的安装

1、下载yii2advanced模板后,解压,在根目录下执行:

./init

会出现提示选择Develop[0]还是Production[1]环境,然后输入yes,就安装完了

2、安装user数据表,advanced模板默认的数据库名称是yii2advanced,在common/config/main-local.php中修改,这个数据库需要提前在你的数据库中创建,在根目录下执行

./yii migrate

yii migrate会自动找到console/migrations下的*_init.php, 也可以在输入./yii查看有哪些命令可用. 有关migrate的具体使用后面会专门讲一下。
顺利的话会提示:

Yii Migration Tool (based on Yii v2.0.12)

Creating migration history table "migration"...Done.
Total 1 new migration to be applied:
    m130524_201442_init

Apply the above migration? (yes|no) [no]:yes
*** applying m130524_201442_init
    > create table {{%user}} ... done (time: 0.026s)
*** applied m130524_201442_init (time: 0.046s)


1 migration was applied.

Migrated up successfully.

当然也有可能会出现错误,我在安装时就报错了:

Exception 'yii\db\Exception'  with message 'SQLSTATE[HY000] [2002] No such file or directory'in
 /Applications/XAMPP/xamppfiles/htdocs/yii_advanced/vendor/yiisoft/yii2/db/Connection.php:534

我的解决方法是,修改common/config/main-local.php中的:

mysql:host=localhost 中改为 host=127.0.0.1

你可能感兴趣的:(yii2-advanced框架的安装)