[Solved] Declaration of Illuminate\Container\Container::get($id) must be compatible with Psr\Container\ContainerInterface::get(string $id)
Problem:
I am trying to install Laravel 8 project, on that time loading the first instance, I got this error - :
Declaration of Illuminate\Container\Container::get($id) must be compatible with Psr\Container\ContainerInterface::get(string $id)
Solution 1:
You should check the version of PHP. It looks like this problem's happening because of the static typing added to psr/container
between v1.0.0 and v.1.1.0 to deprecate PHP < 7.2
https://github.com/php-fig/container/blob/1.0.0/src/ContainerInterface.php#L23
https://github.com/php-fig/container/blob/1.1.0/src/ContainerInterface.php#L22
Pinning psr/container
to v1.0.0 should resolve this until Illuminate is updated
Solution 2:
Upgraded composer version 1.10 to 2.0. The composer will downgrade to version 1.0.0 of Psr\Container and if you need to go back to composer 1 use the command
composer self --1
Thank you for reading the article. If you face any problems, please comment below.