Yii2 使用一 安装

jerry Yii2 2015年11月15日 收藏

一、安装

  1. composer global require "fxp/composer-asset-plugin:1.0.0-beta4"

composer安装使用使用教程请看PHP 依赖管理工具Composer的使用


二、安装应用程序模板

  1. composer create-project --prefer-dist yiisoft/yii2-app-basic basic

安装过程中,由于超出github限额,以前提示输入github账号和密码;

现在改为输入Token,按提示打开它的网址:

  1. https://github.com/settings/tokens/new?scopes=repo&description=Composer+on+PC201412132247+2015-05-08+1725

Create Token后,输入命令行的Token(Hidden)后面,回车。

下载完成后,

访问:

  1. http://localhost/basic/web/index.php

显示界面,安装成功。

其它:

检查Yii基本环境需求:

  1. http://localhost/basic/requirements.php

生产环境中,要设置文档根目录并设置UrlRewrite:

  1.     <VirtualHost *:8080>  
  2.         ServerAdmin webmaster@dummy-host2.example.com  
  3.         DocumentRoot "C:/xampp/htdocs/test/basic/web"  
  4.         ServerName test.com  
  5.         ErrorLog "logs/test.com-error.log"  
  6.         CustomLog "logs/dummy-test.com-access.log" common  
  7.       
  8.         <Directory "C:/xampp/htdocs/test/basic/web">  
  9.          RewriteEngine on  
  10.         # 如果请求的是真实存在的文件或目录,直接访问  
  11.         RewriteCond %{REQUEST_FILENAME} !-f  
  12.         RewriteCond %{REQUEST_FILENAME} !-d  
  13.         # 如果请求的不是真实文件或目录,分发请求至 index.php  
  14.         RewriteRule . index.php  
  15.        </Directory>  
  16.       
  17.     </VirtualHost>