I have recently upgraded Laravel in the project from 5.8.* to 6.x version.
Now when I try running command composer dump-autoload -o
, I get this error:
Declaration of App\Exceptions\Handler::renderHttpException(Symfony\Component\HttpKernel\Exception\HttpException $e)
should be compatible with Illuminate\Foundation\Exceptions\Handler::renderHttpException(Symfony\Component\HttpKern
el\Exception\HttpExceptionInterface $e)
Below is the composer.json
set in the project, when I upgraded Laravel from 5.7.* to 5.8.*, then also I got this same error as above, but I upgraded further hoping that would fix the issue:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"repositories": [
{
"type": "composer",
"url": "https://packages.[company_api].com"
}
],
"require": {
"php": ">=7.1.3",
"basemkhirat/elasticsearch": "^1.3",
"botman/botman": "^2.5",
"botman/driver-web": "^1.5",
"deployer/deployer": "^6.0",
"fideloper/proxy": "^4.0",
"guzzlehttp/guzzle": "^6.3",
"jenssegers/agent": "^2.6",
"jimmiw/php-time-ago": "^2.0",
"laravel/framework": "^6.0",
"laravel/scout": "^8.0",
"laravel/tinker": "~1.0",
"[company_name]/wordpressblogapi": "1.4.*"
},
"require-dev": {
"filp/whoops": "~2.0",
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~7.0"
},
"autoload": {
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": {
"App\\": "app/"
},
"files": [
"helpers/helpers.php"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"post-root-package-install": [
"php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
}
}
I have referred the docs and it doesn't specifically say about any Exception
or Handler.php
file changes, so anyone do suggest how to resolve this...
This is a 5.7 to 5.8 upgrade issue, as you point out when the problem started. The signature of that method changed:
"The
renderHttpException
method signature of theIlluminate\Foundation\Exceptions\Handler
class has changed. If you are overriding this method in your exception handler, you should update the method signature to match its parent:"
/**
* Render the given HttpException.
*
* @param \Symfony\Component\HttpKernel\Exception\HttpExceptionInterface $e
* @return \Symfony\Component\HttpFoundation\Response
*/
protected function renderHttpException(HttpExceptionInterface $e);