laravel command命令行
生成类
为了创建一个新命令,你可以使用Artisan中的 command:make 命令生成一个骨架作为你的起点:
生成一个命令类
php artisan command:make FooCommand
默认情况下,生成的类文件被存放在 app/commands 目录下,同时你也可以指定自定义目录和命名空间:
php artisan command:make FooCommand --path=app/classes --namespace=Classes
注册命令
一旦你的命令完成后,你需要使用 Artisan 进行注册,这样才能够被使用。这通常在 app/start/artisan.php文件中完成。在这个文件中,你可以使用 Artisan::add 函数注册命令:
注册一个 Artisan 命令
Artisan::add(new CustomCommand);
如果你的命令在应用程序的 IoC 容器 中注册,你可以使用 Artisan::resolve 函数使它对 Artisan 可用:
注册一个在 IoC 容器中的命令
Artisan::resolve('binding.name');
一个发邮件样例:
<?php use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument; class SendMailCommand extends Command { /**
* The console command name.
*
* @var string
*/
protected $name = 'SendMailCommand:sendMail';//命令名,命令行调用使用php artisian 这里的$name值 /**
* The console command description.
*
* @var string
*/
protected $description = 'send mail.'; /**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
} /**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
//
$command=" C:/sendEmail -f from.sina.com -t to@qq.com -s smtp.sina.com -xu username -xp pasword -u test ";
$message=$this->argument('message');
$str="$command -m $message ";
$this->info($str);
system($str);
$this->info("It's Done, have a good day."); } /**
* Get the console command arguments.
*
* @return array
*/
protected function getArguments()
{
return array(
array('message', InputArgument::REQUIRED, 'An example argument.'),
);
} /**
* Get the console command options.
*
* @return array
*/
protected function getOptions()
{
return array(
//array('example', null, InputOption::VALUE_OPTIONAL, 'An example option.', null),
);
} }
运行:
php artisan commanname argx --option=bar --option=baz
参考:
http://www.golaravel.com/docs/4.0/commands/
http://www.sitepoint.com/create-laravel-css-minify-command/
laravel command命令行的更多相关文章
- 1)实际时间(real time): 从command命令行开始执行到运行终止的消逝时间; 2)用户CPU时间(user CPU time): 命令执行完成花费的用户CPU时间,即命令在用户态中执行时间总和; 3)系统CPU时间(system CPU time): 命令执行完成花费的系统CPU时
1)实际时间(real time): 从command命令行开始执行到运行终止的消逝时间: 2)用户CPU时间(user CPU time): 命令执行完成花费的用户CPU时间,即命令在用户态中执行时 ...
- Laravel常用命令行中文版
1.生成控制器 php artisan make:controller ArticleController 对应的会在app/http/controllers下面生成ArticleController ...
- windows下安装python、环境设置、多python版本的切换、pyserial与多版本python安装、windows命令行下切换目录
1.windows下安装python 官网下载安装即可 2.安装后的环境设置 我的电脑--属性--高级--设置path的地方添加python安装目录,如C:\Python27;C:\Python33 ...
- java命令行导出、导入sql文件
@IocBean public class SqlCommandModel{ //用户名 @Inject("java:$conf.get('jdbc.username')") pr ...
- Mac系统终端命令行不执行命令 总出现command not found解决方法
配置过安卓开发环境,改过bash_profile这个文件,最后不知怎么的只有cd命令能执行,我猜测可能修改bash_profile文件后没有保存 导致的 保存命令是: source .bas ...
- Qt_Window@Qt Command Prompt从命令行创建工程
#include <QApplication> #include <QLabel> int main(int argc, char *argv[]) { QApplicatio ...
- MAC 命令行工具(Command Line Tools)安装
不过升级后安装命令行工具(Command Line Tools)时发现官网没有clt的下载安装包了,原来改了,使用命令在线安装. 打开终端,输入命令:xcode-select --install 选择 ...
- mac下使用命令行打包出现bash gradle command not found的解决方案
命令行打包的时候出现 bash gradle command not found这个问题,主要是因为gradle环境丢失.需要重新配置gradle的环境变量. 1. gradle路径的查找 然后gra ...
- Windows命令行command的Shell命令详细解析和语法
CMD命令大全及详细解释和语法 Microsoft Windows XP [版本 5.1.2600] 有关某个命令的详细信息,请键入 HELP 命令名 ASSOC 显示或修改文件扩展名关联. A ...
随机推荐
- idea,eclipse创建多模块项目
新建一个maven项目 iead,新建是不选择archetype,新建好之后,pom中的 <packaging>pom</packaging>节点是默认的,如果不是要改成这这样 ...
- Hive学习笔记——保存select结果,Join,多重插入
1. 保存select查询结果的几种方式: 1.将查询结果保存到一张新的hive表中 create table t_tmp as select * from t_p; 2.将查询结果保存到一张已经存在 ...
- git clone ....git
[root@st153 git_test3]# git clone git@gitlab.gaobo.com:root/pythontest1.gitCloning into 'pythontest1 ...
- java项目的部署
1.将tomocat解压到服务器上 2.放项目war包. 3.war包解压. 4.修改端口配置. 1.<Server port="8024" shutdown="S ...
- JS 怎么刷新当前页面
reload 方法,该方法强迫浏览器刷新当前页面. 语法:location.reload([bForceGet]) 参数: bForceGet, 可选参数, 默认为 false,从客户端缓存里取当前页 ...
- ar0331
aptina公司出品 分三个文档:ar0331_ds.pdf 数据表ar0331_dg.pdf 开发指导ar0331_rr_d.pdf 相关寄存器 色调映射(Tone Mapping):http:// ...
- Enterprise Architect UML建模
UML建模 前言 UML建模资料已经很多了,有人想用有人不用,有人会用也有人不会用,本文只是作者的一篇UML建模总结,不想去写太细,因为真正的你去用下,去画下就基本都会了.工具毕竟是工具,设计和思想才 ...
- this,你是谁?
在js中this不像其它语言那样容易理解,它有时候指window对象,有时候又是其它对象,那么this,你到底是谁呢?要分析this就要先理解js中的方法定义,因为this一般都是在方法中使用的,而且 ...
- Hadoop2的HA安装(high availability):nfs+zookeeper
前面介绍过hadoop的简单安装和FA安装,在这里将介绍几种hadoop2中HA(高可用性)安装,HA技术使hadoop不再存在单点namenode的故障. 先来第一种:nfs+zookeeper H ...
- BZOJ 3362 Navigation Nightmare 带权并查集
题目大意:给定一些点之间的位置关系,求两个点之间的曼哈顿距离 此题土豪题.只是POJ也有一道相同的题,能够刷一下 别被题目坑到了,这题不强制在线.把询问离线处理就可以 然后就是带权并查集的问题了.. ...