【发布时间】:2015-05-29 06:27:56
【问题描述】:
我正在尝试使用 php artisan 在 Laravel 中创建一个自定义命令,但尽管我完成了这里写的所有内容:http://laravel.com/docs/4.2/commands,包括命令的注册,但当我键入时它仍然没有在命令列表中列出php工匠。
这是命令:
<?php
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
class PremiumSets extends Command {
protected $name = 'sets:check';
protected $description = 'Check if any of the users did not select a premium set.';
public function __construct()
{
parent::__construct();
}
public function fire()
{
Log::error("PremiumSets Here");
}
protected function getArguments()
{
return [];
}
protected function getOptions()
{
return [];
}
}
?>
\app\start\artisan.php(我也试过使用 Artisan::resolve(),但还是不行)
<?php
/*
|--------------------------------------------------------------------------
| Register The Artisan Commands
|--------------------------------------------------------------------------
|
| Each available Artisan command must be registered with the console so
| that it is available to be called. We'll register every command so
| the console gets access to each of the command object instances.
|
*/
Artisan::add(new PremiumSets);
【问题讨论】:
-
你试过运行
composer dump吗? -
你的命令的文件位置和文件名是什么?
-
我尝试了作曲家转储,仍然没有运气。位置是\app\commands\PremiumSets.php
标签: laravel laravel-4 command laravel-artisan