1.通过composer 安装高级版
C:wampwwwyii>composer create-project --prefer-dist yiisoft/yii2-app-advanced advanced
2. 进入 advanced 目录中 执行 init 初始化
C:wampwwwyii>cd advanced C:wampwwwyiiadvanced>init Yii Application Initialization Tool v1.0 Which environment do you want the application to be initialized in? [0] Development [1] Production Your choice [0-1, or “q” to quit] 0 Initialize the application under ‘Development’ environment? [yes|no] y Start initialization … generate backend/config/main-local.php generate backend/config/params-local.php generate backend/web/index-test.php generate backend/web/index.php generate common/config/main-local.php generate common/config/params-local.php generate console/config/main-local.php generate console/config/params-local.php generate frontend/config/main-local.php generate frontend/config/params-local.php generate frontend/web/index-test.php generate frontend/web/index.php generate yii generate cookie validation key in backend/config/main-local.php generate cookie validation key in frontend/config/main-local.php chmod 0777 backend/runtime chmod 0777 backend/web/assets chmod 0777 frontend/runtime chmod 0777 frontend/web/assets chmod 0755 yii … initialization completed.
Database Exception – yiidbException SQLSTATE[HY000] [1049] Unknown database ‘yii2advanced’ ? Caused by: PDOException SQLSTATE[HY000] [1049] Unknown database ‘yii2advanced’
mysql> create database yii2advanced; Query OK, 1 row affected (0.01 sec)
<?php return [ 'components' => [ 'db' => [ 'class' => 'yiidbConnection', 'dsn' => 'mysql:host=localhost;dbname=yii2advanced', 'username' => 'root', 'password' => '', 'charset' => 'utf8', ], 'mailer' => [ 'class' => 'yiiswiftmailerMailer', '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, ], ], ];
C:wampwwwyiiadvanced>yii migrate Yii Migration Tool (based on Yii v2.0.0) Creating migration history table “migration”…done. Total 1 new migration to be applied: m130524_201442_init Apply the above migration? (yes|no) [no]:y *** applying m130524_201442_init > create table {{%user}} … done (time: 0.031s) *** applied m130524_201442_init (time: 0.055s) Migrated up successfully.
高级应用程序模板现在是全功能。这个安装和基本安装有很大的区别。主要的不同点是,先进的模板有三个入口点的应用程序。这将是前端,后端,和控制台。除此之外,还有一个全新的目录结构,你需要熟悉。(此处略过了)
Yii2的高级应用程序模板,主要分 前台 、后台、console 等三部分功能模块
配置自定义域名 就要分前后台
127.0.0.1 yiiadvanced.com 127.0.0.1 admin.yiiadvanced.com
DocumentRoot “C:/wamp/www/yii/advanced/frontend/web” ServerName yiiadvanced.com DocumentRoot “C:/wamp/www/yii/advanced/backend/web” ServerName admin.yiiadvanced.com
http://yiiadvanced.com 前台
http://admin.yiiadvanced.com 后台