http://wuhai.blog.51cto.com/2023916/760902
yii提供了强大的命令行工具来快速的创建相关组件和应用。
下面就来讲解用yiic工具快速创建yii应用
我的web目录在 d:www下 yiiframework在 D:wwwyiiframework
win平台 cd 进入 wwwyiiframework 目录
运行cmd命令
C:Users******>d:
*【切换到D盘】
D:>cd wwwyiiframework
D:wwwyiiframework>yiic webapp ../testapp/
*创建一个testapp应用在framework上一级目录【回车】
Create a Web application under 'D:wwwyii estapp'? [Yes|No] y
*【选择y/yes回车】
mkdir D:/www/yii/testapp
mkdir D:/www/yii/testapp/assets
mkdir D:/www/yii/testapp/css
generate css/bg.gif
generate css/form.css
generate css/ie.css
generate css/main.css
generate css/print.css
generate css/screen.css
mkdir D:/www/yii/testapp/images
generate index-test.php
generate index.php
mkdir D:/www/yii/testapp/protected
generate protected/.htaccess
mkdir D:/www/yii/testapp/protected/commands
mkdir D:/www/yii/testapp/protected/commands/shell
mkdir D:/www/yii/testapp/protected/components
generate protected/components/Controller.php
generate protected/components/UserIdentity.php
mkdir D:/www/yii/testapp/protected/config
generate protected/config/console.php
generate protected/config/main.php
generate protected/config/test.php
mkdir D:/www/yii/testapp/protected/controllers
generate protected/controllers/SiteController.php
mkdir D:/www/yii/testapp/protected/data
generate protected/data/schema.mysql.sql
generate protected/data/schema.sqlite.sql
generate protected/data/testdrive.db
mkdir D:/www/yii/testapp/protected/extensions
mkdir D:/www/yii/testapp/protected/messages
mkdir D:/www/yii/testapp/protected/migrations
mkdir D:/www/yii/testapp/protected/models
generate protected/models/ContactForm.php
generate protected/models/LoginForm.php
mkdir D:/www/yii/testapp/protected/runtime
mkdir D:/www/yii/testapp/protected/tests
generate protected/tests/bootstrap.php
mkdir D:/www/yii/testapp/protected/tests/fixtures
mkdir D:/www/yii/testapp/protected/tests/functional
generate protected/tests/functional/SiteTest.php
generate protected/tests/phpunit.xml
mkdir D:/www/yii/testapp/protected/tests/report
mkdir D:/www/yii/testapp/protected/tests/unit
generate protected/tests/WebTestCase.php
mkdir D:/www/yii/testapp/protected/views
mkdir D:/www/yii/testapp/protected/views/layouts
generate protected/views/layouts/column1.php
generate protected/views/layouts/column2.php
generate protected/views/layouts/main.php
mkdir D:/www/yii/testapp/protected/views/site
generate protected/views/site/contact.php
generate protected/views/site/error.php
generate protected/views/site/index.php
generate protected/views/site/login.php
mkdir D:/www/yii/testapp/protected/views/site/pages
generate protected/views/site/pages/about.php
generate protected/yiic
generate protected/yiic.bat
generate protected/yiic.php
mkdir D:/www/yii/testapp/themes
mkdir D:/www/yii/testapp/themes/classic
mkdir D:/www/yii/testapp/themes/classic/views
generate themes/classic/views/.htaccess
mkdir D:/www/yii/testapp/themes/classic/views/layouts
mkdir D:/www/yii/testapp/themes/classic/views/site
mkdir D:/www/yii/testapp/themes/classic/views/system
Your application has been created successfully under
ok 到这里yii新应用已经创建成功
用win+wamp的的朋友可能会遇到下面的问题:
在执行yiic webapp命令时,就报以下错误了: ‘"php.exe"’ 不是内部或外部命令,也不是可运行的程序或批处理文件。
这个事yiic批处理程序找不到php.exe引起的
方法一、修改yiic.bat文件
打开yii安装目录d:/www/yii/framework/yiic.bat,yiic.bat有记事本打开有如下一行:
if "%PHP_COMMAND%" == "" set PHP_COMMAND=php.exe
if "%PHP_COMMAND%" == "" set PHP_COMMAND=D:wampphpphp.exe
方法二、将php和yii framework 加入环境变量
在我的电脑右键->属性
确定
完成