yii console
Here is a step by step to show how to run command in the server with yii framework.
1. Create the web application.
yiic webapp ./myapp
2. Edit myapp/protected/config/console.php:
returnarray(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'My Console Application', 'params'=>array(
'testparam'=>'testvalue',
),
);
3. Create myapp/protected/commands/DemoCommand.php:
<?php
class DemoCommand extends CConsoleCommand { publicfunction run($args)
{
echo"Hello! Param=".Yii::app()->params['testparam']."\n";
}
}
4. Check that yiic finds the command:
david_lee@david-desktop:~$/var/www/webapp/protected/yiic
Tip: make sure that you have the php bin in /usr/bin.
Then you will get the message as below:
Yii command runner (based on Yii v1.1.3)
Usage: ./protected/yiic <command-name> [parameters...] The following commands are available:
- demo
- message
- shell
- webapp
5. Run the command:
david_lee@david-desktop:~$ /var/www/webapp/protected/yiic demo
You will get the output:
Hello!Param=testvalue
Tip: You have to pay attention that the name of the command above: yiic demo. Please compare with the name of myapp/protected/commands/DemoCommand.php
Have fun with Yii!
Yii console 的db 如果是localhost需要修改为127.0.0.1
yii console的更多相关文章
- Yii console 创建命令行应用
大家都知道PHP的程序没有进程概念,而且生命周期极短,无法实现一些定时计划或者是计划任务,今天我们看看在YII框架中如何使用计划任务创建命令行应用. 1.在 console/controllers 文 ...
- yii console.php 报错 Property "CConsoleApplication.theme" is not defined.
默认配置的话,是不会出现这个错误的,应该是有人为修改了 yiic.php 这个文件,本来是 $config 载入的应该是 console.php ,人为修改后载入了 main.php 这个配置文件了 ...
- Yii2 定时任务创建(Console 任务)
Yii2的定时任务可以有两种写法,原理都是通过服务器的定时任务去调用 1.通过调用指定的URL访问 就相当于在浏览器中访问 2.通过console调用 下面我们就来说说Console 是如何实现定时任 ...
- Yii应用的目录结构和入口脚本
以下是一个通过高级模版安装后典型的Yii应用的目录结构: . ├── backend ├── common ├── console ├── environments ├── frontend ├── ...
- Yii源码阅读笔记(二十六)
Application 类中设置路径的方法和调用ServiceLocator(服务定位器)加载运行时的组件的方法注释: /** * Handles the specified request. * 处 ...
- Yii源码阅读笔记(二十一)——请求处理流程
Yii2请求处理流程: 首先:项目路径/web/index.php (new yii\web\Application($config))->run();//根据配置文件创建App实例,先实例化y ...
- Yii源码阅读笔记(三)
接着上次的继续阅读BaseYii.php vendor/yiisoft/yii2/BaseYii.php—— public static function getRootAlias($alias)// ...
- yii2 ./yii command : No such file or directory
git clone下来的yii2后台项目,由于需要执行 ./yii migrate命令.执行之后,提示 No such file or directory 我从同样为yii2 basic的./yii ...
- 【Yii系列】Yii2.0基础框架
缘起 因为一个月的短暂停留,我在给朋友搞事情,所以Yii系列的文章耽搁了很长时间,现在又重拾当时的知识,给大伙好好撸下这一系列的博客 提起Yii,虽然是国外的开发者搞的,但是它的作者是华人,这才是让我 ...
随机推荐
- scala学习手记26 - 重用函数值
函数值对消除代码重复有很大的帮助.但是像函数值这样直接将一个函数作为另一个函数的参数却不太利于函数值本身的重用. 来看一个例子: class Equipment(val routine: Int =& ...
- JNIjw04
1.VC6(CPP)的DLL代码: #include<stdio.h> #include "jniZ_JNIjw04.h" #include <string> ...
- ReflectionZ_测试_01
1.Java代码 public class TreflectionZ { public static void main(String[] args) throws Exception { Class ...
- ps切图步骤
1.复制图层到新建 2.alt + i + r 裁剪 依次按 3.ctrl + alt + shift + s 保存 裁剪图标 复制到图层 , 删除背景,并复制样式 就可以做到 背景透明.
- 滚动条——WPF ScrollViewer的应用
WPF ScrollViewer的应用 我们知道在一个限定高的窗体和容器中,想要把内容显示完是有些问题的,这个时候我们就要使用类似于浏览器的那个滚动条的效果了,在wpf中也同样如此,最近就碰到了这 ...
- 转:走近NoSQL数据库的四大家族
在目前的企业IT架构中,系统管理员以及DBA都会考虑使用NoSQL数据库来解决RDBMS所不能解决的问题,特别是互联网行业.传统的关系型数据库主要以表(table)的形式来存储数据,而无法应对非结构化 ...
- Win7系统搭建WiFi热点详细攻略
(转自:http://blog.csdn.net/gisredevelopment/article/details/16113889) 一.如果你之前没有在笔记本上搭建过WiFi,那么恭喜你,你的笔记 ...
- TreeView.ImageSet 属性
TreeView.ImageSet 属性 .NET Framework 2.0 注意:此属性在 .NET Framework 2.0 版中是新增的. 获取或设置用于 TreeView ...
- sphinx使用
一. 1.先得包含下载的文件 include'./sphinx/api/sphinxapi.php'; $sphinx= new SphinxClient(); $sphinx->SetServ ...
- 关于iframe和div窗口中ajax请求200状态时执行的回调问题
上一篇说了在ajax回调里面处理iframe窗口的刷新问题,这一篇记录一下遇到的一个分别在iframe和div窗口中ajax请求200状态时执行的回调问题. 我们先来看一下ajax请求的写法(这里使用 ...