mardi 14 décembre 2021

Upgrade to Laravel 6 - Uncaught Error: Class 'Request' not found in app/Exceptions/Handler.php

I am currently upgrading from L5.8 to L6. I have read over the upgrade docs and made changes where necessary, if any. Once I changed the composer.json version to ^6.0 and ran composer update, I am getting the following stack trace.

This is on macOS running php 7.4

composer update
Loading composer repositories with package information
Updating dependencies
Nothing to modify in lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Package jakub-onderka/php-console-color is abandoned, you should avoid using it. Use php-parallel-lint/php-console-color instead.
Package jakub-onderka/php-console-highlighter is abandoned, you should avoid using it. Use php-parallel-lint/php-console-highlighter instead.
Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
Package fzaninotto/faker is abandoned, you should avoid using it. No replacement was suggested.
Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested.
Package phpunit/phpunit-mock-objects is abandoned, you should avoid using it. No replacement was suggested.
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover
PHP Fatal error:  Uncaught Error: Class 'Request' not found in /Users/ryahn/Public/Sites/alphacoder/rework/app/Exceptions/Handler.php:43
Stack trace:
#0 /Users/ryahn/Public/Sites/alphacoder/rework/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(376): App\Exceptions\Handler->report(Object(Symfony\Component\Debug\Exception\FatalThrowableError))
#1 /Users/ryahn/Public/Sites/alphacoder/rework/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(141): Illuminate\Foundation\Console\Kernel->reportException(Object(Symfony\Component\Debug\Exception\FatalThrowableError))
#2 /Users/ryahn/Public/Sites/alphacoder/rework/artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 {main}
  thrown in /Users/ryahn/Public/Sites/alphacoder/rework/app/Exceptions/Handler.php on line 43

Fatal error: Uncaught Error: Class 'Request' not found in /Users/ryahn/Public/Sites/alphacoder/rework/app/Exceptions/Handler.php:43
Stack trace:
#0 /Users/ryahn/Public/Sites/alphacoder/rework/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(376): App\Exceptions\Handler->report(Object(Symfony\Component\Debug\Exception\FatalThrowableError))
#1 /Users/ryahn/Public/Sites/alphacoder/rework/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(141): Illuminate\Foundation\Console\Kernel->reportException(Object(Symfony\Component\Debug\Exception\FatalThrowableError))
#2 /Users/ryahn/Public/Sites/alphacoder/rework/artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 {main}
  thrown in /Users/ryahn/Public/Sites/alphacoder/rework/app/Exceptions/Handler.php on line 43
Script @php artisan package:discover handling the post-autoload-dump event returned with error code 255

This is the Handler.php file its referencing to

<?php

namespace App\Exceptions;

use Exception;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Support\Facades\Log;
use Request;
use Symfony\Component\HttpKernel\Exception\HttpException;

class Handler extends ExceptionHandler
{
    /**
     * A list of the exception types that are not reported.
     *
     * @var array
     */
    protected $dontReport = [
        //
    ];

    /**
     * A list of the inputs that are never flashed for validation exceptions.
     *
     * @var array
     */
    protected $dontFlash = [
        'password',
        'password_confirmation',
    ];

    /**
     * Report or log an exception.
     *
     * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
     *
     * @param  \Exception  $exception
     * @return void
     */
    public function report(Exception $exception)
    {
        if ($exception instanceof HttpException === false) {
            $request = Request::all();
            Log::info("Error on page: " . Request::url());
            Log::info("Request data: " . htmlspecialchars(json_encode($request)));
        }

        parent::report($exception);
    }

    /**
     * Render an exception into an HTTP response.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Exception  $exception
     * @return \Illuminate\Http\Response
     */
    public function render($request, Exception $exception)
    {
        return parent::render($request, $exception);
    }
}

line 43: $request = Request::all();

I have tried to run php artisan config:cache and php artisan config:clear but still get the following stack trace.

I am most likely focusing on the wrong part of the stack trace. Hopefully its not something obvious I am over looking.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3m5RtMS
via IFTTT

Aucun commentaire:

Enregistrer un commentaire