我使用Laravel 4.1和工匠工具为我们的网站开发一些cli脚本。 这些脚本将通过cron作业在后台运行。Laravel工匠命令行
我遇到了一个错误/功能,并想知道是否有其他人遇到这个问题或知道如何克服这个问题。
说明:
在启动文件夹下artisan.php我已经加了我的命令:
Artisan::add(new VinCommand);
Artisan::add(new DealersCommand);
Artisan::add(new ReportingCommand);
Artisan::add(new AutoInventoryCommand);
Artisan::add(new VastLeadsCommand);
Artisan::add(new SendInventoryAlertsCommand);
Artisan::add(new JumpstartCapCommand);
在应用程序 - >命令我有我的所有命令。 在AutoInventoryCommand.php我在__construct方法中运行截断表,但我发现每个cli命令都调用truncate。
例如VinCommand:
php artisan command:vin_command
也运行AutoInventoryCommands __construct方法,这是造成总是被截断的表。
是否将常规知识放在__construct方法中?
在其他一些命令中,我在__contruct方法中设置了私有静态变量。这是不好的做法。我应该有一个被调用的_init()方法:
public function fire()
{
$this->_init();
}
这将设置我的变量。如果我没有:
echo "Table Truncated \n";
在截断方法中,我从来没有抓到过。
所以这是一个bug /常识
我认为发生这种情况,因为当所有的__constructs被称为:
Artisan::add();
叫?