登录  
 加关注
查看详情
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

820716的博客-知识分享 向上的心!

知识分享 开阔向上的心胸! http://www.820716.net/blog

 
 
 

日志

 
 

yii框架搭建项目,gii生成模块代码,数据模型代码,curl代码,yii的URL伪静态 URL重写  

2013-12-16 09:29:25|  分类: 默认分类 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
==================================================================
==================================================================
========================创建项目结构==========================================
==================================================================
==========// yiic自动代码生成
 
yiic是自动代码生成工具,可以生成应用基本框架。
 
 
开始---运行  --- 输入 cmd  确定 ----- 输入命令   "path" 确定 
 
D:\xampp\php;D:\htdocs\yii1114f0fee9\framework;
 
C:\Users\Administrator>d:
D:\>cd htdocs
D:\htdocs>cd yii1114f0fee9
D:\htdocs\yii1114f0fee9>dir
 
 
 
#假设YiiRoot为Yii的安装目录,AppRoot(不用创建,将自动生成)为即将安装的YiiRoot下的目录,则在dos命令行中运行yiic命令即可完成框架的自动生成。
 
#YiiRoot = D:\htdocs\yii1114f0fee9\framework
#AppRoot = 即将创建的项目的目录名
 
#创建项目的命令行为
#YiiRoot/framework/yiic webapp YiiRoot/AppRoot
 
#cmd下输入命令行 ”yiic webapp  项目名“ 例如下边实例  项目名为cme。
D:\htdocs\yii1114f0fee9>yiic webapp cme
Create a Web application under 'D:\htdocs\yii1114f0fee9\cme'? (yes|no) [no]:y
      mkdir D:/htdocs/yii1114f0fee9/cme/assets
      mkdir D:/htdocs/yii1114f0fee9/cme/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:/htdocs/yii1114f0fee9/cme/images
   generate index-test.php
   generate index.php
      mkdir D:/htdocs/yii1114f0fee9/cme/protected
   generate protected/.htaccess
      mkdir D:/htdocs/yii1114f0fee9/cme/protected/commands
      mkdir D:/htdocs/yii1114f0fee9/cme/protected/commands/shell
      mkdir D:/htdocs/yii1114f0fee9/cme/protected/components
   generate protected/components/Controller.php
   generate protected/components/UserIdentity.php
      mkdir D:/htdocs/yii1114f0fee9/cme/protected/config
   generate protected/config/console.php
   generate protected/config/main.php
   generate protected/config/test.php
      mkdir D:/htdocs/yii1114f0fee9/cme/protected/controllers
   generate protected/controllers/SiteController.php
      mkdir D:/htdocs/yii1114f0fee9/cme/protected/data
   generate protected/data/schema.mysql.sql
   generate protected/data/schema.sqlite.sql
   generate protected/data/testdrive.db
      mkdir D:/htdocs/yii1114f0fee9/cme/protected/extensions
      mkdir D:/htdocs/yii1114f0fee9/cme/protected/messages
      mkdir D:/htdocs/yii1114f0fee9/cme/protected/migrations
      mkdir D:/htdocs/yii1114f0fee9/cme/protected/models
   generate protected/models/ContactForm.php
   generate protected/models/LoginForm.php
      mkdir D:/htdocs/yii1114f0fee9/cme/protected/runtime
      mkdir D:/htdocs/yii1114f0fee9/cme/protected/tests
   generate protected/tests/bootstrap.php
      mkdir D:/htdocs/yii1114f0fee9/cme/protected/tests/fixtures
      mkdir D:/htdocs/yii1114f0fee9/cme/protected/tests/functional
   generate protected/tests/functional/SiteTest.php
   generate protected/tests/phpunit.xml
      mkdir D:/htdocs/yii1114f0fee9/cme/protected/tests/report
      mkdir D:/htdocs/yii1114f0fee9/cme/protected/tests/unit
   generate protected/tests/WebTestCase.php
      mkdir D:/htdocs/yii1114f0fee9/cme/protected/vendor
      mkdir D:/htdocs/yii1114f0fee9/cme/protected/views
      mkdir D:/htdocs/yii1114f0fee9/cme/protected/views/layouts
   generate protected/views/layouts/column1.php
   generate protected/views/layouts/column2.php
   generate protected/views/layouts/main.php
      mkdir D:/htdocs/yii1114f0fee9/cme/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:/htdocs/yii1114f0fee9/cme/protected/views/site/pages
   generate protected/views/site/pages/about.php
   generate protected/yiic
   generate protected/yiic.bat
   generate protected/yiic.php
      mkdir D:/htdocs/yii1114f0fee9/cme/themes
      mkdir D:/htdocs/yii1114f0fee9/cme/themes/classic
      mkdir D:/htdocs/yii1114f0fee9/cme/themes/classic/views
   generate themes/classic/views/.htaccess
      mkdir D:/htdocs/yii1114f0fee9/cme/themes/classic/views/layouts
      mkdir D:/htdocs/yii1114f0fee9/cme/themes/classic/views/site
      mkdir D:/htdocs/yii1114f0fee9/cme/themes/classic/views/system
 
Your application has been created successfully under D:\htdocs\yii1114f0fee9\cme
.
 
D:\htdocs\yii1114f0fee9>
 
 
 
 
#注意: 在 MacOS、Linux 或 Unix 系统中运行  yiic 时,你可能需要修改  yiic 文件的权限使它能够运行。
 
#你也可以用  php YiiRoot/framework/yiic.php 来代替  yiic。
 
#这将在  WebRoot/AppRoot目录下建立一个最基本的 Yii 应用,WebRoot 代表你的 Web 服务器根目录。
 
#这个应用具有所有必须的目录和文件,因此可以方便地在此基础上添加更多功能。
 
==================================================================
==================================================================
========================GII创建项目 共用的1套 基础的 数据模型==========================================
==================================================================
==========// 创建项目-数据模型
Model Generator
 
Table Name = pe_system_user
 
Model Class = SystemUser
 
Base Class = CActiveRecord
 
Model Path = application.modules
 
==================================================================
==================================================================
========================GII创建项目 N个模块==========================================
=========================管理模块=========================================
==================================================================
 
// 创建项目模块
Module Generator
 
Module ID  = admini
// 作为管理后台的模块 index.php?r=admini
 
 
 
 
// 创建数据库的crud模型  ActiveRecord
Crud Generator
 
// 增加了项目分类模块 .modules.admini
Model Class = application.modules.admini.models.SystemUser
 
// 增加了项目分类模块 admini/
admini/systemUser = admini/systemUser
 
// 修改了基类 XAdminiBase
Base Controller Class = XAdminiBase
 
 
==================================================================
==================================================================
========================GII创建项目  Crud==========================================
=========================数据库表操作=========================================
==================================================================
 
foreach==========// 创建数据库的crud模型  ActiveRecord
Crud Generator
 
// 选择 共用的 数据模型Model
Model Class = application.models.Notice
 
// 增加了项目分类模块 recommend/
Controller ID = recommend/notice
 
// 修改了基类 XAdminiBase
Base Controller Class = XAdminiBase
 
==================================================================
============================YII URL重写======================================
==================================================================
==================================================================
 
 
目标:把这个url重写成下面那种
http://localhost/yii/index.php?r=site/login
 
一、确定你的apache有rewrite模块,可以通过phpinfo()来查看。
没有怎么办?自己百度
 
二、编辑yii的配置文件 main.php
找到
 
/*
'urlManager'=>array(
'urlFormat'=>'path',
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
),
),
*/
把注释去掉
现在应该可以看到效果了,但是还是有写瑕疵,我们要吧入口文件index.php去掉
三、在网站根目录新建一个文件.htaccess
 
<IfModule rewrite_module>
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
</IfModule>
ok虽然去掉index.php也不报错,但是默认路径还是带了index.php
最后一步,更改配置文件main.php
找到
1
'urlFormat'=>'path',
在它下面增加
1
'showScriptName'=>false,
大功告成!!
 
 
 
 

QQ:84047848

  评论这张
 
阅读(836)| 评论(0)

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018