Framework: [7.x] Declaration of Illuminate\Http\Request::get($key, $default = NULL) should be compatible with Symfony\Component\HttpFoundation\Request::get(string $key, $default = NULL)

Created on 8 Mar 2020  路  2Comments  路  Source: laravel/framework

  • Laravel Version: 7.0.7
  • PHP Version: 7.3.5
  • Database Driver & Version:

Description:

I'm trying to setup my fresh laravel 7 application but I got below errors:

2020/03/08 15:05:05 [error] 12519#12519: *1 FastCGI sent in stderr: "PHP message: PHP Warning:  Declaration of Illuminate\Http\Request::get($key, $default = NULL) should be compatible with Symfony\Component\HttpFoundation\Request::get(string $key, $default = NULL) in /var/www/myapp/vendor/laravel/framework/src/Illuminate/Http/Request.php on line 20
PHP message: PHP Fatal error:  Declaration of Carbon\Translator::setLocale($locale) must be compatible with Symfony\Contracts\Translation\LocaleAwareInterface::setLocale(string $locale) in /var/www/myapp/vendor/nesbot/carbon/src/Carbon/Translator.php on line 18
PHP message: PHP Fatal error:  Uncaught TypeError: Return value of Symfony\Component\HttpFoundation\Response::setStatusCode() must be an instance of Symfony\Component\HttpFoundation\object, instance of Symfony\Component\HttpFoundation\Response returned in /var/www/myapp/vendor/symfony/http-foundation/Response.php:450
Stack trace:
#0 /var/www/myapp/vendor/symfony/http-foundation/Response.php(198): Symfony\Component\HttpFoundation\Response->setStatusCode(500)
#1 /var/www/myapp/vendor/symfony/http-foundation/Response.php(214): Symfony\Component\HttpFoundation\Response->__construct('<!doctype html>...', 500, Array)
#2 /var/www/myapp/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(328): Symfony\Component\HttpFoundation\Response::create('<!doctype html>...', 500, Array)
#3 /var/www/myapp/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(305): Illuminate\Foundation\Exceptions\Handler-" while reading response header from upstream, client: 10.0.0.1, server: myapp.local, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.3-fpm.sock:", host: "myapp.local"

Basically:

  • Declaration of Illuminate\Http\Request::get($key, $default = NULL) should be compatible with Symfony\Component\HttpFoundation\Request::get(string $key, $default = NULL) in /var/www/myapp/vendor/laravel/framework/src/Illuminate/Http/Request.php on line 20
  • Declaration of CarbonTranslator::setLocale($locale) must be compatible with Symfony\ContractsTranslation\LocaleAwareInterface::setLocale(string $locale) in /var/www/myapp/vendor/nesbot/carbon/src/Carbon/Translator.php on line 18
  • Return value of Symfony\Component\HttpFoundation\Response::setStatusCode() must be an instance of Symfony\Component\HttpFoundation\object, instance of Symfony\Component\HttpFoundation\Response returned in /var/www/myapp/vendor/symfony/http-foundation/Response.php:450

Steps To Reproduce:

  1. laravel new myapp
  2. visit the website

Most helpful comment

Sorry, was incorrectly pointed to 7.1 fpm. After changing to 7.3 all works fine.

All 2 comments

Sorry, was incorrectly pointed to 7.1 fpm. After changing to 7.3 all works fine.

For anyone getting this, try every php version above 7.2 you can. 7.4 worked for me

Was this page helpful?
0 / 5 - 0 ratings