队列::推送错误 - laravel

时间:2018-06-02 05:11:51

标签: php laravel laravel-5 queue laravel-queue

我的laravel项目中的token_request <- POST(url = 'https://api.twitter.com/oauth2/token' , body = 'grant_type=client_credentials' , add_headers(.headers = c('Authorization'= 'xxxxxxxxxxxxxxxxxx' , 'Content-Type' = 'application/x-www-form-urlencoded'))) token_body <- content(token_request, as = 'parsed') 中包含此代码:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    //Create cell here
    UITableViewCell *cell;
    cell= (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];

    //Add gesture to cell here
    UILongPressGestureRecognizer *longTap = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longTapGestureCaptured:)];
    longTap.minimumPressDuration=1.5f;
    longTap.delegate=self;
    [cell addGestureRecognizer:longTap];

    cell.textLabel.text = @"Name";//Send your data here

    return cell;

}

-(void)longTapGestureCaptured:(UILongPressGestureRecognizer *)gesture
{
    NSLog(@"Long tap"); // never called
}

但是当我向web.php发送请求时我有错误

 Route::get('/', function () {
    Queue::push(function(){
        Log::info('12');
        return 'done';
    });
});

我试过这样但我有同样的错误:

http://localhost:8000/
  

Laravel verrsion是: 5.6

2 个答案:

答案 0 :(得分:0)

我认为你的代码中有一个拼写错误,确保这不是问题:

Route::get('/', function () {
Queue::push(function($job){
    Log::info('12');
    return 'done';
    $job->delete();
});
 });

$hob替换为$job

答案 1 :(得分:0)

可能你不允许在Queue::push内传递封闭。

您需要像这样传递Job类:

Queue::push(MyNewJob::class, $data);

MyNewJob应该是这样的:

class MyNewJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    public function handle()
    {
       Log::info('12');
    }
}