本文介绍了Illuminate \ Container \ Container :: get($ id)的声明必须与Psr \ Container \ ContainerInterface :: get(string $ id)兼容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

安装了新的Laravel 8项目,并且在加载第一个实例时,出现以下错误.这是很奇怪的原因,因为我将其放在一旁,后来又从Laravel 5.8升级了另一个项目(运行正常)->6,并且在我去检查站点时遇到了类似的错误.

Installed new Laravel 8 project and upon loading the first instance, I get the below error. It's weird cause I put it aside and later on upgraded another project (which was working fine) from Laravel 5.8 -> 6 and got the similar error when I went to check the site out.

我已经清除了作曲家的缓存,删除了vendor文件夹并重新安装,似乎无法弄清楚.在过去的一天里,我一直在脑筋急转弯,似乎某些软件包版本不正确,但是我不确定从哪里开始进行故障排除.

I've cleared the composer cache, deleted the vendor folder and reinstalled and can't seem to figure it out. Been racking my brain around this for the past day and it seems like some package version is incorrect but I'm not sure where to begin troubleshooting.

(!)致命错误:Illuminate \ Container \ Container :: get($ id)声明必须与/home/vagrant/ps/vendor/中的Psr \ Container \ ContainerInterface :: get(string $ id)兼容第15行上的laravel/framework/src/Illuminate/Container/Container.php

( ! ) Fatal error: Declaration of Illuminate\Container\Container::get($id) must be compatible with Psr\Container\ContainerInterface::get(string $id) in /home/vagrant/ps/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 15

Call Stack
#   Time    Memory  Function    Location
1   0.0001  357784  {main}( )   .../index.php:0
2   0.0133  502360  require_once( '/home/vagrant/ps/bootstrap/app.php' )    .../index.php:47
3   0.0133  502360  spl_autoload_call ( )   .../app.php:14
4   0.0133  502424  Composer\Autoload\ClassLoader->loadClass( ) .../app.php:14
5   0.0133  502424  Composer\Autoload\includeFile( )    .../ClassLoader.php:322
6   0.0135  578336  include( '/home/vagrant/ps/vendor/laravel/framework/src/Illuminate/Foundation/Application.php' )    .../ClassLoader.php:444
7   0.0135  578336  spl_autoload_call ( )   .../Application.php:29
8   0.0135  578392  Composer\Autoload\ClassLoader->loadClass( ) .../Application.php:29
9   0.0135  578392  Composer\Autoload\includeFile( )    .../ClassLoader.php:322
10  0.0138  588440  include( '/home/vagrant/ps/vendor/laravel/framework/src/Illuminate/Container/Container.php' )   .../ClassLoader.php:444

推荐答案

您正在使用哪个版本的PHP?似乎发生了此问题,因为在五天前发布的v1.0.0和v.1.1.0之间的 psr/container 中添加了静态类型以弃用PHP<7.2

What version of PHP are you using? 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 released five days ago 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.0.1/src/ContainerInterface.php#L23

psr/container 固定到v1.0.0可以解决此问题,直到更新Illuminate

Pinning psr/container to v1.0.0 should resolve this until Illuminate is updated

这篇关于Illuminate \ Container \ Container :: get($ id)的声明必须与Psr \ Container \ ContainerInterface :: get(string $ id)兼容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 09:58