执行yiic命令提示’php.exe’将YII添加到系统环境变量

还有个问题就是每次执行yiic命令时要把yiic的全路径打出来才行,比如我的yii框架在F:\myproject里面,我每次执行的时候都要

F:\myproject\yii\framework\yiic webapp yiiblog

我们可以把yiic也加入系统环境变量,加入以下代码:

假如php.exe这个目录在E:\Server\php

F:\myproject\yii\framework\
此时我们执行yiic再不用打全路径了,这样方便多了.

>yiic webapp yiiblog

执行了yiic批处理之后,会提示YES/NO 选择./////////////////////////

log如下:
Create a Web application under ‘F:\myproject\djcms’? [Yes|No] yes
mkdir F:/myproject/djcms
mkdir F:/myproject/djcms/assets
mkdir F:/myproject/djcms/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 F:/myproject/djcms/images
generate index-test.php
generate index.php
mkdir F:/myproject/djcms/protected
generate protected/.htaccess
mkdir F:/myproject/djcms/protected/commands
mkdir F:/myproject/djcms/protected/commands/shell
mkdir F:/myproject/djcms/protected/components
generate protected/components/Controller.php
generate protected/components/UserIdentity.php
mkdir F:/myproject/djcms/protected/config
generate protected/config/console.php
generate protected/config/main.php
generate protected/config/test.php
mkdir F:/myproject/djcms/protected/controllers
generate protected/controllers/SiteController.php
mkdir F:/myproject/djcms/protected/data
generate protected/data/schema.mysql.sql
generate protected/data/schema.sqlite.sql
generate protected/data/testdrive.db
mkdir F:/myproject/djcms/protected/extensions
mkdir F:/myproject/djcms/protected/messages
mkdir F:/myproject/djcms/protected/models
generate protected/models/ContactForm.php
generate protected/models/LoginForm.php
mkdir F:/myproject/djcms/protected/runtime
mkdir F:/myproject/djcms/protected/tests
generate protected/tests/bootstrap.php
mkdir F:/myproject/djcms/protected/tests/fixtures
mkdir F:/myproject/djcms/protected/tests/functional
generate protected/tests/functional/SiteTest.php
generate protected/tests/phpunit.xml
mkdir F:/myproject/djcms/protected/tests/report
mkdir F:/myproject/djcms/protected/tests/unit
generate protected/tests/WebTestCase.php
mkdir F:/myproject/djcms/protected/views
mkdir F:/myproject/djcms/protected/views/layouts
generate protected/views/layouts/column1.php
generate protected/views/layouts/column2.php
generate protected/views/layouts/main.php
mkdir F:/myproject/djcms/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 F:/myproject/djcms/protected/views/site/pages
generate protected/views/site/pages/about.php
generate protected/yiic
generate protected/yiic.bat
generate protected/yiic.php
mkdir F:/myproject/djcms/themes
mkdir F:/myproject/djcms/themes/classic
mkdir F:/myproject/djcms/themes/classic/views
generate themes/classic/views/.htaccess
mkdir F:/myproject/djcms/themes/classic/views/layouts
mkdir F:/myproject/djcms/themes/classic/views/site
mkdir F:/myproject/djcms/themes/classic/views/system

Your application has been created successfully under F:\myproject\djcms.

F:\myproject>

打开 D:\web\yii\blog\protected\config\main.php 文件

修改里面的

'db'=>array(
   'connectionString'=>'mysql:host=localhost;dbname=blog', //数据库类型;主机地址=localhost;数据库名=blog
   'username' => 'root', //数据库账号
   'password' => 'root', //数据库密码
   'charset' => 'utf8', //数据库编码
  ),

保存。

在命令行进入到 F:/myproject/djcms/

执行命令:

.\protected\yiic.bat shell

输入之后进入

然后用 model 等建立 model

用 crud 等建立 controllers 目录下的文件。

建立这个的时候 views 下面自动建立了对应的文件及以及下面的一些文件。

One Response to “执行yiic命令提示’php.exe’将YII添加到系统环境变量”

Leave a Reply

(will not be published)