Hello yii2

  1. 安装composer,并执行:
    # composer global require "fxp/composer-asset-plugin:~1.1.0"
  2. 根据模板创建项目
    # composer create-project --prefer-dist yiisoft/yii2-app-basic basic
    # composer create-project --prefer-dist --stability=dev yiisoft/yii2-app-advanced yiicomm
  3. yii2-app-advanced执行如下命令:
    • # init#初始化环境
    • 初始化数库:common/config/main-local.php要求db name为yii2advanced,并执行yii migrate来做数据迁移。
  4. # netstat -ano#查看端口占用
  5. C:\Windows\System32\drivers\etc\hosts

    127.0.0.1       www.a.com
    
  6. D:\xampp\apache\conf\extra\httpd-vhosts.conf

    NameVirtualHost *:80
    
    
        DocumentRoot D:/xampp/htdocs/
        ServerName localhost
    
    
    
        ##ServerAdmin [email protected]
        DocumentRoot "D:/work_php/"
        ServerName www.a.com
        
            Require all granted
        
    
    
  7. 访问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

  1. 用这个 https://github.com/deerawan/yii2-advanced-api
  2. enable rewrite module in XAMPP
  3. 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"
        }
    }
    

你可能感兴趣的:(前端开发,yii2)