Laravel 开发遇到的相关问题

问题1、job 队列任务代码修改后不生效

对 laravel job 队列的代码进行了修改,但是没有生效,查看了一下官方手册,原来要执行一下:


  php artisan queue:restart
 

问题2、执行job里的任务命令


  php artisan queue:work redis --queue=gdt
  //gdt是队列的名称   redis队列存放的位置
  

问题3、使用laravel下载excel出现报错,只需要修改跨域中间件就好了

Call to undefined method Symfony\Component\HttpFoundation\BinaryFileResponse::header()


public function handle($request, Closure $next)
{
    if($request->isMethod('OPTIONS')) {
         $response = response('', 200);
    } else {
        $response = $next($request);
    }

    $IlluminateResponse = 'Illuminate\Http\Response';
    $SymfonyResopnse = 'Symfony\Component\HttpFoundation\Response';
    $headers = [
        'Access-Control-Allow-Origin' => '*',
        'Access-Control-Allow-Methods' => 'POST, GET, OPTIONS, PUT, PATCH, DELETE',
        'Access-Control-Allow-Headers' => 'Access-Control-Allow-Headers, Origin,Accept, X-Requested-With, Content-Type, Access-Control-Request-Method, Authorization , Access-Control-Request-Headers, X-CSRF-TOKEN'
    ];

    if ($response instanceof $IlluminateResponse) {
        $response->header('Access-Control-Allow-Methods', 'HEAD, GET, POST, PUT, PATCH, DELETE');
        $response->header('Access-Control-Allow-Headers', $request->header('Access-Control-Request-Headers'));
        $response->header('Access-Control-Allow-Origin', '*');
        return $response;
    }

    if ($response instanceof $SymfonyResopnse) {
        foreach ($headers as $key => $value) {
            $response->headers->set($key, $value);
        }
        return $response;
    }
    return $response;

}

你可能感兴趣的:(laravel,php)