- 安装composer,并执行:
# composer global require "fxp/composer-asset-plugin:~1.1.0"
- 根据模板创建项目
# composer create-project --prefer-dist yiisoft/yii2-app-basic basic
# composer create-project --prefer-dist --stability=dev yiisoft/yii2-app-advanced yiicomm
- yii2-app-advanced执行如下命令:
# init
#初始化环境- 初始化数库:
common/config/main-local.php
要求db name为yii2advanced
,并执行yii migrate
来做数据迁移。
# netstat -ano
#查看端口占用C:\Windows\System32\drivers\etc\hosts
127.0.0.1 www.a.com
D:\xampp\apache\conf\extra\httpd-vhosts.conf
NameVirtualHost *:80 <VirtualHost *:80> DocumentRoot D:/xampp/htdocs/ ServerName localhost </VirtualHost> <VirtualHost *:80> ##ServerAdmin webmaster@dummy-host.example.com DocumentRoot "D:/work_php/" ServerName www.a.com <Directory "D:/work_php/"> Require all granted </Directory> </VirtualHost>
访问http://www.a.com/basic/web/,http://www.a.com/yiicomm/frontend/web/
解决使用 Composer 的时候提示输入 Token
进入 https://github.com/settings/tokens 点击 「Generate new token」 新建一个 Token,选择默认新建就行,然后就会得到一个 Token,然后输入这个值就 OK 了。
rest api
- 用这个 https://github.com/deerawan/yii2-advanced-api
- enable rewrite module in XAMPP
Cannot update yii2 via composer bower-asset/jquery could not be found
# composer global require "fxp/composer-asset-plugin:~1.1.1"
you also need to add the following code to your project’s composer.json file:"extra": { "asset-installer-paths": { "npm-asset-library": "vendor/npm", "bower-asset-library": "vendor/bower" } }