首页 文章

从laravel 5升级到laravel 5.5导致错误Argument 1传递给App \ Exceptions \ Handler :: report()

提问于
浏览
0

我们正在尝试将我们的laravel 5.0项目升级到最新版本的laravel(laravel 5.5也可以)以支持php7.1 . 当我们运行composer install laravel时会出现以下错误:

[Symfony \ Component \ Debug \ Exception \ FatalErrorException]未捕获的TypeError:传递给App \ Exceptions \ Handler :: report()的参数1必须是Exception的实例,在给定的错误的情况下,在C:\ xampp7 \ htdocs中调用\ VEK第73行上的Lexmond \ vendor \ laravel \ framework \ src \ Illuminate \ Foundation \ Boot strap \ HandleExceptions.php,在C:\ xampp7 \ htdocs \ V.E.K中定义 . Lexmond \ app \ Exceptions \ Handler.php:25堆栈跟踪:#0 C:\ xampp7 \ htdocs \ V.E.K . Lexmond \ vendor \ laravel \ framework \ src \ Illuminate \ Foundation \ Bootstrap \ HandleExceptions.ph p(73):App \ Exceptions \ Handler-> report(Object(Error))#1 [internal function]:Illuminate \ Foundation \ Bootstrap \ HandleExceptions-> handleException(Object(Error))#2 抛出

这个错误的原因是什么?我们希望有人能解决我们的问题 .

先感谢您!

WeTalkive

3 回答

  • 0

    你可以在bootstrap / app.php中发布你的内容吗?

    还要检查你是否在该文件中

    $app->singleton(
    Illuminate\Contracts\Debug\ExceptionHandler::class,
    App\Exceptions\Handler::class
    

    );

  • 0

    Handler.php

    使用例外;使用Illuminate \ Foundation \ Exceptions \ Handler作为ExceptionHandler;

    class Handler扩展ExceptionHandler {

    /**
     * A list of the exception types that should not be reported.
     *
     * @var array
     */
    protected $dontReport = [
        'Symfony\Component\HttpKernel\Exception\HttpException'
    ];
    
    /**
     * Report or log an exception.
     *
     * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
     *
     * @param  \Exception  $e
     * @return void
     */
    public function report(Exception $e)
    {
        return parent::report($e);
    }
    
    /**
     * Render an exception into an HTTP response.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Exception  $e
     * @return \Illuminate\Http\Response
     */
    public function render($request, Exception $e)
    {
        return parent::render($request, $e);
    }
    

    }

  • 0
    <?php
    
    /*
    |--------------------------------------------------------------------------
    | Create The Application
    |--------------------------------------------------------------------------
    |
    | The first thing we will do is create a new Laravel application instance
    | which serves as the "glue" for all the components of Laravel, and is
    | the IoC container for the system binding all of the various parts.
    |
    */
    
    $app = new Illuminate\Foundation\Application(
        realpath(__DIR__.'/../')
    );
    
    /*
    |--------------------------------------------------------------------------
    | Bind Important Interfaces
    |--------------------------------------------------------------------------
    |
    | Next, we need to bind some important interfaces into the container so
    | we will be able to resolve them when needed. The kernels serve the
    | incoming requests to this application from both the web and CLI.
    |
    */
    
    $app->singleton(
        'Illuminate\Contracts\Http\Kernel',
        'App\Http\Kernel'
    );
    
    $app->singleton(
        'Illuminate\Contracts\Console\Kernel',
        'App\Console\Kernel'
    );
    
    $app->singleton(
        'Illuminate\Contracts\Debug\ExceptionHandler',
        'App\Exceptions\Handler'
    );
    
    /*
    |--------------------------------------------------------------------------
    | Return The Application
    |--------------------------------------------------------------------------
    |
    | This script returns the application instance. The instance is given to
    | the calling script so we can separate the building of the instances
    | from the actual running of the application and sending responses.
    |
    */
    
    return $app;
    

相关问题