YII 系统命令行生成代码

简介:

1.cmd输入(已经加入YII framework到环境变量)

Java代码   收藏代码
  1. yiic shell "E:\Apache2\htdocs\test\index.php"  

 或

Java代码   收藏代码
  1. E:\Apache2\htdocs\test\protected>yiic shell "E:\Apache2\htdocs\test\index.php"  

 SHELL代码或屏幕回显 :

Java代码   收藏代码
  1. Yii Interactive Tool v1.1  
  2. Please type 'help' for help. Type 'exit' to quit.  

你当前显示的是与shell交互的提示符。你可以输入help查看shell为你提供的所有命令列表

Java代码   收藏代码
  1. >> help  
  2. At the prompt, you may enter a PHP statement or one of the following commands:  
  3.  - controller  
  4.  - crud  
  5.  - form  
  6.  - help  
  7.  - model  
  8.  - module  
  9. Type 'help <command-name>' for details about a command.   

 我们看了有几个可选的命令,有一个controller命令看起来象是我们想要的,可能是用来为应用程序创建一个控制器的命令。我们可以在shell提标符下进一步了解controller命令的更多帮助信息。这些信息包括提供的用法说明,参数描述和一些例子。

Java代码   收藏代码
  1. >> help controller  
  2. USAGE  
  3.     controller <controller-ID> [action-ID] ...  
  4.    
  5. DESCRIPTION  
  6.     This command generates a controller and views associated with the specified actions.  
  7.    
  8. PARAMETERS  
  9.   * controller-ID: required, controller ID, e.g., 'post'.  
  10.      If the controller should be located under a subdirectory,   
  11.      please specify the controller ID as 'path/to/ControllerID',  
  12.      e.g., 'admin/user'.  
  13.    
  14.      If the controller belongs to a module, please specify   
  15.      the controller ID as 'ModuleID/ControllerID' or   
  16.      'ModuleID/path/to/Controller' (assuming the controller is under a subdirectory of that module).  
  17.    
  18.   * action-ID: optional, action ID. You may supply one or several action IDs.   
  19.      A default 'index' action will always be generated.  
  20.    
  21. EXAMPLES  
  22.   * Generates the 'post' controller:  
  23.             controller post  
  24.    
  25.   * Generates the 'post' controller with additional actions 'contact' and 'about':  
  26.             controller post contact about   
  27.    
  28.   * Generates the 'post' controller which should be located under  
  29.     the 'admin' subdirectory of the base controller path:  
  30.             controller admin/post  
  31.    
  32.   * Generates the 'post' controller which should belong to the 'admin' module:  
  33.             controller admin/post  

 阅读帮助,很明显看出该命令会生成控制器和操作方法及视图文件。由于我们将要做的应用程序主要是显示一条消息,让我们调用controller message 和一个要显示的操作方法:

Java代码   收藏代码
  1. >> controller message helloWorld  
  2. generate MessageController.php  
  3.                mkdir /Webroot/demo/protected/views/message  
  4.         generate helloworld.php  
  5.         generate index.php  
  6.    
  7. Controller 'message' has been created in the following file:   
  8.         /Webroot/demo/protected/controllers/MessageController.php  
  9.    
  10. You may access it in the browser using the following URL:   
  11.         http://hostname/path/to/index.php?r=message  
  12. >>  

 1.model

Java代码   收藏代码
  1. >> model User tbl_user  
  2.    generate models/User.php  
  3.    generate fixtures/tbl_user.php  
  4.    generate unit/UserTest.php  
  5.   
  6. The following model classes are successfully generated:  
  7.     User  
  8.   
  9. If you have a 'db' database connection, you can test these models now with:  
  10.     $model=User::model()->find();  
  11.     print_r($model);  

 2. CURD

Java代码   收藏代码
  1. >> crud User  
  2.    generate UserController.php  
  3.    generate UserTest.php  
  4.    mkdir D:/testdrive/protected/views/user  
  5.    generate create.php  
  6.    generate update.php  
  7.    generate index.php  
  8.    generate view.php  
  9.    generate admin.php  
  10.    generate _form.php  
  11.    generate _view.php  
  12.   
  13. Crud 'user' has been successfully created. You may access it via:  

 3.module

Java代码   收藏代码
  1. >> module wiki  
  2.       mkdir E:/Apache2/htdocs/webapp/protected/modules  
  3.       mkdir E:/Apache2/htdocs/webapp/protected/modules/wiki  
  4.       mkdir E:/Apache2/htdocs/webapp/protected/modules/wiki/components  
  5.       mkdir E:/Apache2/htdocs/webapp/protected/modules/wiki/controllers  
  6.    generate controllers/DefaultController.php  
  7.       mkdir E:/Apache2/htdocs/webapp/protected/modules/wiki/messages  
  8.       mkdir E:/Apache2/htdocs/webapp/protected/modules/wiki/models  
  9.       mkdir E:/Apache2/htdocs/webapp/protected/modules/wiki/views  
  10.       mkdir E:/Apache2/htdocs/webapp/protected/modules/wiki/views/default  
  11.    generate views/default/index.php  
  12.       mkdir E:/Apache2/htdocs/webapp/protected/modules/wiki/views/layouts  
  13.    generate WikiModule.php  
  14.   
  15. Module 'wiki' has been created under the following folder:  
  16.     E:\Apache2\htdocs\webapp\protected\modules\wiki  
  17.   
  18. You may access it in the browser using the following URL:  
  19.     http://hostname/path/to/index.php?r=wiki  
  20.   
  21. Note, the module needs to be installed first by adding 'wiki'  
  22. to the 'modules' property in the application configuration.  

 4.

相关文章
|
5月前
|
SQL 小程序 Shell
PHP代码审计(三)php中代码执行&&命令执行函数
string system(string command,int &return_var) 可以用来执行系统命令并直接将相应的执行结果输出 system() 输出并返回最后一行shell结果。
55 0
|
JavaScript 前端开发 小程序
【小程序】WXS脚本
【小程序】WXS脚本
132 0
【小程序】WXS脚本
|
JavaScript 前端开发 网络协议
Frida - App逆向 JavaScript代码注入 常用语法介绍
Frida可以通过将JavaScript 脚本插入到APP的内存中来对APP的逻辑进行跟踪和监视乃至修改原程序的逻辑,实现逆向开发和分析人员想要实现的功能称之为HOOK(钩子 即通过钩子机制与钩子函数建立联系);
935 0
Frida - App逆向 JavaScript代码注入 常用语法介绍
|
Shell 开发工具 git
easyswoole 更新代码shell
easyswoole 更新代码shell
59 0
|
PHP 数据库
PHP异常处理函数,Thinkphp调试
在thinkphp中,除了异常类携带的简单file、code、message、trace等 还会获取当前服务器的配置、脚本的参数(get/post…)、数据库查询语句等 然后组合成一个有排版、数据充足的页面展示给我们,方便了我们排查问题。
104 0
PHP异常处理函数,Thinkphp调试
|
Shell PHP
运行php代码的几种方式
运行php代码的几种方式
221 0
|
JavaScript 前端开发 Shell
能用js实现的最终用js实现,Shell脚本也不例外
能用js实现的最终用js实现,Shell脚本也不例外
能用js实现的最终用js实现,Shell脚本也不例外
|
缓存 自然语言处理 关系型数据库
PHP代码的执行
先看下PHP的结构图
PHP代码的执行
脚本比别人的代码都多
脚本比别人的代码都多
100 0
|
PHP
YII2 配置gii之后页面404 解决 2点=1 要加载model,2 要设置环境为dev,如下截图 3次要---有时候可能需要 执行composer dump-autoload 重新加载类
YII2 配置gii之后页面404  解决 2点=1 要加载model,2 要设置环境为dev,如下截图 解决成功     我的是这么解决的
1139 0