运行工匠司令部的PHP弃用问题

发布于 2025-01-24 12:34:29 字数 8609 浏览 5 评论 0原文

每当我运行工匠命令时,我都会遇到这个问题。

我正在使用代客和PHP 8.1。我尝试更改PHP版本,但我仍然遇到了这个问题。

当我运行时:

jakefeeley@Jakes-MBP marketing % php artisan plugin:install vojtasvoboda.twigextensions

返回:

PHP Deprecated:  Return type of Illuminate\Container\Container::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/jakefeeley/Sites/certhub/marketing/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 1231

Deprecated: Return type of Illuminate\Container\Container::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/jakefeeley/Sites/certhub/marketing/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 1231
PHP Deprecated:  Return type of Illuminate\Container\Container::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/jakefeeley/Sites/certhub/marketing/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 1242

Deprecated: Return type of October\Rain\Config\Repository::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/jakefeeley/Sites/certhub/marketing/vendor/october/rain/src/Config/Repository.php on line 446
PHP Deprecated:  Return type of October\Rain\Config\Repository::offsetSet($key, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/jakefeeley/Sites/certhub/marketing/vendor/october/rain/src/Config/Repository.php on line 458

Deprecated: Return type of October\Rain\Config\Repository::offsetSet($key, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/jakefeeley/Sites/certhub/marketing/vendor/october/rain/src/Config/Repository.php on line 458
PHP Deprecated:  Return type of October\Rain\Config\Repository::offsetUnset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/jakefeeley/Sites/certhub/marketing/vendor/october/rain/src/Config/Repository.php on line 469

Deprecated: Return type of October\Rain\Config\Repository::offsetUnset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/jakefeeley/Sites/certhub/marketing/vendor/october/rain/src/Config/Repository.php on line 469
PHP Fatal error:  During inheritance of ArrayAccess: Uncaught ErrorException: Return type of Illuminate\Support\Collection::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/jakefeeley/Sites/certhub/marketing/vendor/laravel/framework/src/Illuminate/Support/Collection.php:1277
Stack trace:
#0 /Users/jakefeeley/Sites/certhub/marketing/vendor/laravel/framework/src/Illuminate/Support/Collection.php(11): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8192, 'Return type of ...', '/Users/jakefeel...', 1277)
#1 /Users/jakefeeley/Sites/certhub/marketing/vendor/composer/ClassLoader.php(478): include('/Users/jakefeel...')
#2 /Users/jakefeeley/Sites/certhub/marketing/vendor/composer/ClassLoader.php(346): Composer\Autoload\includeFile('/Users/jakefeel...')
#3 

In Collection.php line 11:
                                                                                                                                                                                                         
  During inheritance of ArrayAccess: Uncaught ErrorException: Return type of Illuminate\Support\Collection::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset  
  ): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/jakefeeley/Sites/certhub/marketing/vendor/laravel/framework/src/Illuminate/Support/Col  
  lection.php:1277                                                                                                                                                                                       
  Stack trace:                                                                                                                                                                                           
  #0 /Users/jakefeeley/Sites/certhub/marketing/vendor/laravel/framework/src/Illuminate/Support/Collection.php(11): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8192, 'Return type of   
  ...', '/Users/jakefeel...', 1277)                                                                                                                                                                      
  #1 /Users/jakefeeley/Sites/certhub/marketing/vendor/composer/ClassLoader.php(478): include('/Users/jakefeel...')                                                                                       
  #2 /Users/jakefeeley/Sites/certhub/marketing/vendor/composer/ClassLoader.php(346): Composer\Autoload\includeFile('/Users/jakefeel...')                                                                 
  #3 /Users/jakefeeley/Sites/certhub/marketing/vendor/october/rain/src/Support/Collection.php(11): Composer\Autoload\ClassLoader->loadClass('Illuminate\\Supp...')                                       
  #4 /Users/jakefeeley/Sites/certhub/marketing/vendor/composer/ClassLoader.php(478): include('/Users/jakefeel...')                                                                                       
  #5 /Users/jakefeeley/Sites/certhub/marketing/vendor/composer/ClassLoader.php(346): Composer\Autoload\includeFile('/Users/jakefeel...')                                                                 
  #6 /Users/jakefeeley/Sites/certhub/marketing/vendor/october/rain/src/Support/helpers.php(269): Composer\Autoload\ClassLoader->loadClass('October\\Rain\\Su...')                                        
  #7 /Users/jakefeeley/Sites/certhub/marketing/vendor/laravel/framework/src/Illuminate/Foundation/PackageManifest.php(89): collect(Array)                                                                
  #8 /Users/jakefeeley/Sites/certhub/marketing/vendor/laravel/framework/src/Illuminate/Foundation/PackageManifest.php(78): Illuminate\Foundation\PackageManifest->config('aliases')                      
  #9 /Users/jakefeeley/Sites/certhub/marketing/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/RegisterFacades.php(26): Illuminate\Foundation\PackageManifest->aliases()                    
  #10 /Users/jakefeeley/Sites/certhub/marketing/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(219): Illuminate\Foundation\Bootstrap\RegisterFacades->bootstrap(Object(October\Rain  
  \Foundation\Application))                                                                                                                                                                              
  #11 /Users/jakefeeley/Sites/certhub/marketing/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(320): Illuminate\Foundation\Application->bootstrapWith(Array)                      
  #12 /Users/jakefeeley/Sites/certhub/marketing/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(129): Illuminate\Foundation\Console\Kernel->bootstrap()                            
  #13 /Users/jakefeeley/Sites/certhub/marketing/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\Co  
  nsoleOutput))                                                                                                                                                                                          
  #14 {main}

Whenever I run an artisan command I am getting this issue.

I am using Valet and PHP 8.1. I have tried changing versions of PHP but I still get this issue.

When i run:

jakefeeley@Jakes-MBP marketing % php artisan plugin:install vojtasvoboda.twigextensions

Returns:

PHP Deprecated:  Return type of Illuminate\Container\Container::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/jakefeeley/Sites/certhub/marketing/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 1231

Deprecated: Return type of Illuminate\Container\Container::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/jakefeeley/Sites/certhub/marketing/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 1231
PHP Deprecated:  Return type of Illuminate\Container\Container::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/jakefeeley/Sites/certhub/marketing/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 1242

Deprecated: Return type of October\Rain\Config\Repository::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/jakefeeley/Sites/certhub/marketing/vendor/october/rain/src/Config/Repository.php on line 446
PHP Deprecated:  Return type of October\Rain\Config\Repository::offsetSet($key, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/jakefeeley/Sites/certhub/marketing/vendor/october/rain/src/Config/Repository.php on line 458

Deprecated: Return type of October\Rain\Config\Repository::offsetSet($key, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/jakefeeley/Sites/certhub/marketing/vendor/october/rain/src/Config/Repository.php on line 458
PHP Deprecated:  Return type of October\Rain\Config\Repository::offsetUnset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/jakefeeley/Sites/certhub/marketing/vendor/october/rain/src/Config/Repository.php on line 469

Deprecated: Return type of October\Rain\Config\Repository::offsetUnset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/jakefeeley/Sites/certhub/marketing/vendor/october/rain/src/Config/Repository.php on line 469
PHP Fatal error:  During inheritance of ArrayAccess: Uncaught ErrorException: Return type of Illuminate\Support\Collection::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/jakefeeley/Sites/certhub/marketing/vendor/laravel/framework/src/Illuminate/Support/Collection.php:1277
Stack trace:
#0 /Users/jakefeeley/Sites/certhub/marketing/vendor/laravel/framework/src/Illuminate/Support/Collection.php(11): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8192, 'Return type of ...', '/Users/jakefeel...', 1277)
#1 /Users/jakefeeley/Sites/certhub/marketing/vendor/composer/ClassLoader.php(478): include('/Users/jakefeel...')
#2 /Users/jakefeeley/Sites/certhub/marketing/vendor/composer/ClassLoader.php(346): Composer\Autoload\includeFile('/Users/jakefeel...')
#3 

In Collection.php line 11:
                                                                                                                                                                                                         
  During inheritance of ArrayAccess: Uncaught ErrorException: Return type of Illuminate\Support\Collection::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset  
  ): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/jakefeeley/Sites/certhub/marketing/vendor/laravel/framework/src/Illuminate/Support/Col  
  lection.php:1277                                                                                                                                                                                       
  Stack trace:                                                                                                                                                                                           
  #0 /Users/jakefeeley/Sites/certhub/marketing/vendor/laravel/framework/src/Illuminate/Support/Collection.php(11): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8192, 'Return type of   
  ...', '/Users/jakefeel...', 1277)                                                                                                                                                                      
  #1 /Users/jakefeeley/Sites/certhub/marketing/vendor/composer/ClassLoader.php(478): include('/Users/jakefeel...')                                                                                       
  #2 /Users/jakefeeley/Sites/certhub/marketing/vendor/composer/ClassLoader.php(346): Composer\Autoload\includeFile('/Users/jakefeel...')                                                                 
  #3 /Users/jakefeeley/Sites/certhub/marketing/vendor/october/rain/src/Support/Collection.php(11): Composer\Autoload\ClassLoader->loadClass('Illuminate\\Supp...')                                       
  #4 /Users/jakefeeley/Sites/certhub/marketing/vendor/composer/ClassLoader.php(478): include('/Users/jakefeel...')                                                                                       
  #5 /Users/jakefeeley/Sites/certhub/marketing/vendor/composer/ClassLoader.php(346): Composer\Autoload\includeFile('/Users/jakefeel...')                                                                 
  #6 /Users/jakefeeley/Sites/certhub/marketing/vendor/october/rain/src/Support/helpers.php(269): Composer\Autoload\ClassLoader->loadClass('October\\Rain\\Su...')                                        
  #7 /Users/jakefeeley/Sites/certhub/marketing/vendor/laravel/framework/src/Illuminate/Foundation/PackageManifest.php(89): collect(Array)                                                                
  #8 /Users/jakefeeley/Sites/certhub/marketing/vendor/laravel/framework/src/Illuminate/Foundation/PackageManifest.php(78): Illuminate\Foundation\PackageManifest->config('aliases')                      
  #9 /Users/jakefeeley/Sites/certhub/marketing/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/RegisterFacades.php(26): Illuminate\Foundation\PackageManifest->aliases()                    
  #10 /Users/jakefeeley/Sites/certhub/marketing/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(219): Illuminate\Foundation\Bootstrap\RegisterFacades->bootstrap(Object(October\Rain  
  \Foundation\Application))                                                                                                                                                                              
  #11 /Users/jakefeeley/Sites/certhub/marketing/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(320): Illuminate\Foundation\Application->bootstrapWith(Array)                      
  #12 /Users/jakefeeley/Sites/certhub/marketing/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(129): Illuminate\Foundation\Console\Kernel->bootstrap()                            
  #13 /Users/jakefeeley/Sites/certhub/marketing/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\Co  
  nsoleOutput))                                                                                                                                                                                          
  #14 {main}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

醉梦枕江山 2025-01-31 12:34:30

在使用Homestead运行Web应用程序(将Laravel与PHP7.3)运行我的Web应用程序时,我遇到了这个错误。我花了很长时间才终于发现我遇到的错误是从主机机器中运行PHP8。

因此,我也将PHP版本从主机机器更改为7.3。

现在问题已经消失了。

我不知道为什么,但是显然,主机机器中的PHP也会影响宅基地中的PHP。

因此,您需要确保Homestead中的PHP版本与主机机器相同。

I got this error whilre running my web app ( using laravel with php7.3 ) using homestead. It took me so long to finally found out that the error I got was from running php8 in the host machine.

So I change the php version from the host machine to 7.3 as well.

Now the problem has all gone.

I dont know why but apparently, the php in the host machine does affect the php in the homesteead as well.

So you need to make sure the php version in homestead is the same as the host machine.

天荒地未老 2025-01-31 12:34:30

查找文件并添加方法标头:

#[\ReturnTypeWillChange]
public function myFun() {
   [...]
}

documentation & 示例

Find the file and add method header:

#[\ReturnTypeWillChange]
public function myFun() {
   [...]
}

Documentation & Example

古镇旧梦 2025-01-31 12:34:30

尝试检查您对composer.json和package.json的依赖性,检查所有依赖性是否在正确的位置(用于生产 - 依赖关系而不是依赖dev)

Try to check your dependences of composer.json and package.json, check if all dependences are in right place (for production->dependences not dependences-dev)

老街孤人 2025-01-31 12:34:29

根据我的经验,这是由于试图根据PHP 8.1运行Laravel 7(或更早)。我知道您说您尝试更改PHP版本,但是我会仔细检查您的更改肯定会生效。

对于Laravel 7,切换回PHP 8.0为我解决了问题。

NB:Laravel 7的Composer.json错误地指定“ php”:“^7.2.5 |^8.0”,,这意味着它 can can 在PHP 8.1。

In my experience this is due to attempting to run Laravel 7 (or earlier) under PHP 8.1. I know you said you tried changing PHP versions, but I would double-check that your changes definitely took effect.

For Laravel 7, switching back to PHP 8.0 fixed the issue for me.

nb: Laravel 7's composer.json incorrectly specifies "php": "^7.2.5|^8.0", which implies it can run under PHP 8.1.

ㄟ。诗瑗 2025-01-31 12:34:29

就我而言,我有Laravel 8.12,然后得到了这个错误。
因此,我将更改为“ laravel/framework”:“^8.12”,“ laravel/framework”:“^8.75”, composer.json中。然后,我在终端上运行了作曲家更新。你去!

*最后,当我运行php工匠 - version我的laravel版本是8.83.1

In my case, i had Laravel 8.12 then i got this error.
so i change "laravel/framework": "^8.12", to "laravel/framework": "^8.75", in Composer.json . then i ran composer update on terminal. there you go!

*at the end, when i ran php artisan --version my laravel version was 8.83.1

深爱不及久伴 2025-01-31 12:34:29

我运行了作曲家的更新,它修复了

I ran composer update and it fixed things

棒棒糖 2025-01-31 12:34:29

当我将PHP版本从7更新为8时,我也遇到了同样的问题。
我将“ Laravel/Framework”更新为“^8.75”,并更新了作曲家更新。这对我有用。

I had the same problem when i update my php version from 7 to 8.
I updated "laravel/framework" to "^8.75" and ran composer update. That works for me.

我一直都在从未离去 2025-01-31 12:34:29

当我尝试在PHP 8.1上运行 Laravel 7.3 时,我遇到了同样的

错误-8.1。

当我在终端上检查PHP版本时,使用php -version
终端向我展示了我正在使用PHP 7.4,

所以我认为Laravel使用的是PHP 7.4,但事实并非如此。以某种方式,Web服务器(NGINX)正在重定向到 php 8.1

确保正在使用哪个PHP版本,请使用内置的phpinfo()方法。 的一种方法

  • 以下是从Laravel项目中备份index.php
  • ,然后从index.php文件中删除所有内容,

然后在index.php文件上添加以下内容

<?php
   phpinfo();
?>

,然后尝试访问您的Laravel项目。
这将为您提供 PHP信息页,其中包括有关Laravel项目实际使用的PHP版本的信息。

当我在Macos Big Sur上使用Homebrew时,我使用这些命令停止了PHP8.1

brew services stop [email protected]
brew unlink [email protected]  

,然后我开始了PHP 7.4

brew services start [email protected]
brew link [email protected]

有关切换PHP版本的更多信息

I got the same error when I tried to run Laravel 7.3 on php 8.1

For me i had 2 versions of php installed on my computer, php-7.4 and php-8.1.

When i checked the php version on the terminal, using php --version
the terminal showed me i was using php 7.4

So I thought php 7.4 was what laravel was using, But that was not the case. Somehow the web server (nginx) was redirecting to php 8.1

To know for sure which php version is being used, use the built-in phpinfo() method. Below is one way to do it

  • backup index.php from your Laravel project
  • Then remove everything from the index.php file

Add the following on index.php file

<?php
   phpinfo();
?>

Then try to access your Laravel project.
That will give you php information page that will include the information about the version of php your Laravel project is actually using.

As I was using homebrew on macOS Big Sur, I used these commands to stop php8.1

brew services stop [email protected]
brew unlink [email protected]  

Then I started php 7.4

brew services start [email protected]
brew link [email protected]

For more info on switching php versions

情痴 2025-01-31 12:34:29

由于Laravel/PHP版本,我遇到了同样的问题,我使用的是Laravel 6.x LTS和PHP 8.1,这是不兼容的,因为您可以在此处检查 https://laravel.com/docs/9.x/releases 这样,您有两种选择升级您的Laravel或降级您的PHP宅基地vagrant因此在您的网站中 homestead的输入。yaml您可以执行类似

sites:
    - map: your-site.local
      to: /home/vagrant/your-site/public
      php: "7.4"

或要使用的任何PHP版本,并运行Vagrant Reload -Provision

I was having same issues due to the laravel/php versions, I was using laravel 6.X LTS and php 8.1 which is not compatible as you can check here https://laravel.com/docs/9.x/releases so you have two choices either upgrade your laravel or downgrade your php, im my case I was using Homestead & Vagrant so in your sites entry of your Homestead.yaml you can do something like

sites:
    - map: your-site.local
      to: /home/vagrant/your-site/public
      php: "7.4"

Or any php version you want to use and run vagrant reload --provision

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文