简体   繁体   中英

Error whille running composer install on PHP 7.2 Ubuntu

I kept getting this error at the end of my composer install on PHP 7.2 - Laravel 5.1

> php artisan clear-compiled
PHP Fatal error:  Uncaught TypeError: Argument 1 passed to App\Exceptions\Handler::report() must be an instance of Exception, instance of Error given, called in /home/forge/bheng/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php on line 73 and defined in /home/forge/bheng/app/Exceptions/Handler.php:29
Stack trace:
#0 /home/forge/bheng/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(73): App\Exceptions\Handler->report(Object(Error))
#1 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(Object(Error))
#2 {main}
  thrown in /home/forge/bheng/app/Exceptions/Handler.php on line 29
[2019-01-31 10:29:34] production.ERROR: Symfony\Component\Debug\Exception\FatalErrorException: Uncaught TypeError: Argument 1 passed to App\Exceptions\Handler::report() must be an instance of Exception, instance of Error given, called in /home/forge/bheng/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php on line 73 and defined in /home/forge/bheng/app/Exceptions/Handler.php:29
Stack trace:
#0 /home/forge/bheng/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(73): App\Exceptions\Handler->report(Object(Error))
#1 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(Object(Error))
#2 {main}
  thrown in /home/forge/bheng/app/Exceptions/Handler.php:29
Stack trace:
#0 {main}  



  [Symfony\Component\Debug\Exception\FatalErrorException]                                                                                                                                                                                                                                                                       
  Uncaught TypeError: Argument 1 passed to App\Exceptions\Handler::report() must be an instance of Exception, instance of Error given, called in /home/forge/bheng/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php on line 73 and defined in /home/forge/bheng/app/Exceptions/Handler.php:29  
  Stack trace:                                                                                                                                                                                                                                                                                                                  
  #0 /home/forge/bheng/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(73): App\Exceptions\Handler->report(Object(Error))                                                                                                                                                                     
  #1 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(Object(Error))                                                                                                                                                                                                                      
  #2 {main}                                                                                                                                                                                                                                                                                                                     
    thrown                                                                                                                                                                                                                                                                                                                      


Script php artisan clear-compiled handling the post-update-cmd event returned with error code 255
┌──[root@bheng]──[/home/forge/bheng] 
└──  

app/Exceptions/Handler.php

<?php namespace App\Exceptions;

use Exception;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Database\Eloquent\ModelNotFoundException as ModelNotFoundException;

use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;


class Handler extends 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)
    {
        if ($this->isHttpException($e))
        {
            return $this->renderHttpException($e);
        }
        else if($e instanceof NotFoundHttpException)
        {
            return response()->view('missing', [], 404);
        }

        else if($e instanceof ModelNotFoundException )
        {
            return response()->view('layouts.share.errors.model_not_found', [], 404);
        }

        else
        {
            return parent::render($request, $e);
        }
    }
}

Detail

在此处输入图片说明


I've tried those 2 commands

在此处输入图片说明

I still get the same result.

How can I prevent that ?

You can run composer install --no-scripts or composer update --no-scripts to install / update any packages, and it will skip running any artisan commands.

You can then try to run php artisan clear-compiled to see if the update has fixed the issue.

If this doesn't work, you should consider upgrading your application to use a newer Laravel version, or downgrade PHP to an older version that is compatible with the version of Laravel you want to use.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM