适用场景:分析数据(日志)
php artisan make:console 你的命令类名
示例:
php artisan make:console Check
在\app\Console\Commands目录下已生成一个Check.php文件
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class Check extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'command:name';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
//
}
}
你可以把$signature改为你要的命令名称
protected $signature = 'check';
此时还不能在控制台中调用,需要在Kernel.php中注册。
protected $commands = [
'App\Console\Commands\Check'
];
你已经可以在控制台中使用这个命令了
php artisan check
点评:似乎也没啥用,因为php本身也可以不用Laravel框架来使用CLI命令行。
laravel ORM 只开启created_at的几种方法总结下面小编就为大家分享一篇laravel ORM 只开启created_at的几种方法总结,具有很好的参考价值,希望对大家有所帮助。一
通过源码解析Laravel的依赖注入这篇文章主要给大家介绍了如何通过源码解析Laravel的依赖注入的相关资料,文中通过示例代码介绍的非常详细,对大
Laravel中unique和exists验证规则的优化详解这篇文章主要给大家介绍了关于Laravel中unique和exists验证规则的优化的相关资料,文中通过示例代码介绍的非常详细,
Laravel 5.5基于内置的Auth模块实现前后台登陆详解最近在使用laravel5.5,利用其实现了一个功能,下面分享给大家,这篇文章主要给大家介绍了关于Laravel 5.5基于内置的
源码分析 Laravel 重复执行同一个队列任务的原因laravel 的队列服务对各种不同的后台队列服务提供了统一的 API,下面这篇文章通过源码分析给大家介绍了关于 Larave
关于 Laravel Redis 多个进程同时取队列问题详解这篇文章主要给大家介绍了关于 Laravel Redis 多个进程同时取队列问题的相关资料,文中通过示例代码介绍的非常详细