您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

聊聊​laravel怎么用命令来执行脚本

2024/3/10 20:11:30发布16次查看
下面由laravel教程栏目带大家介绍laravel怎么用命令来执行脚本,希望对大家有所帮助!
laravel 使用命令执行脚本
1.生成console文件
php artisan make:console testconsole --command=laravel:test
2.handle方法中编辑业务逻辑
<?phpnamespace app\console\commands;use illuminate\console\command;class hellolaravelacademy extends command{ /** * the name and signature of the console command. * * @var string */ protected $signature = 'laravel:test {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() { echo $this->argument("name").php_eol; echo 123; }}
$signature为是否接收参数,?表示非必须。 arguement接收参数
执行
php artisan laravel:test php artisan laravel:test xiaoming
【相关推荐:最新的五个laravel视频教程】
以上就是聊聊​laravel怎么用命令来执行脚本的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product