[英]PHP artisan command run error in laravel4
我的項目使用Laravel4和mongoDB創建。 我使用laravel artisan創建了一個命令,並在Laravel中使用此命令php artisan taxi:checktrips
checktrips進行檢查行程。 Laravel Runs中的以下命令:
public function schedule(Schedulable $scheduler)
{
return $scheduler->everyMinutes(.06);
}
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
while (true) {
try {
sleep(2);
foreach ($this->redis->keys('trip_id*') as $key) {
$trip_id = explode('|', $key);
$trip_id = $trip_id[1];
if ($this->driver->closest($trip_id)) {
echo 'Closest, Add trip_temp_id Redis';
$this->redis->set('trip_temp_id|'.$trip_id,
(int) $this->redis->get($key));
Log::importRedis('trip_temp_id|'.$trip_id, $trip_id);
}
echo "{$trip_id}, Deleted Redis";
$this->redis->del($key);
Log::exportRedis($key, $trip_id);
}
foreach ($this->redis->keys('trip_temp_id*') as $key) {
$trip_id = explode('|', $key);
$trip_id = $trip_id[1];
if (\Carbon\Carbon::now()->timestamp > (int) $this->redis->get($key)) {
echo 'Deleting Temp Redis';
$this->redis->del($key);
Log::exportRedis($key, $trip_id);
$this->driver->rejectTrip($trip_id);
}
}
} catch (\Exception $e) {
Log::errorLog([
'file' => $e->getFile(),
'line' => $e->getLine(),
'code' => $e->getCode(),
'message' => $e->getMessage(),
'trace' => $e->getTrace(),
'trace_string' => $e->getTraceAsString(),
'previous' => $e->getPrevious(),
]);
}
}
}
}
但是當我執行時顯示:
[MongoException]
zero-length keys are not allowed, did you use $ with double quotes?
我該如何解決該問題而沒有任何問題?
我認為您應該確保$trip_id
具有有效值。
例如,您使用:
$trip_id = explode('|', $key);
$trip_id = $trip_id[1];
您確定要在此處使用索引1
而不是0
嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.