PHP运行artisan命令时出现过时问题

new9mtju  于 2023-01-19  发布在  PHP
关注(0)|答案(8)|浏览(634)

每当我运行一个工匠命令,我得到这个问题。
我正在使用代客泊车和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}
00jrzges

00jrzges1#

根据我的经验,这是由于试图在PHP 8.1下运行Laravel 7(或更早版本)。我知道你说你试图更改PHP版本,但我会仔细检查你的更改是否确实生效。
对于Laravel 7,切换回PHP 8.0为我修复了这个问题。
注意:Laravel 7的composer.json错误地指定了"php": "^7.2.5|^8.0",,这意味着它 * 可以 * 在PHP 8.1下运行。

6ojccjat

6ojccjat2#

在我的情况下,我有Laravel 8.12,然后我得到了这个错误。所以我改变"laravel/framework": "^8.12","laravel/framework": "^8.75",在Composer.json。然后我运行composer update在终端上。

  • 最后,当我运行php artisan --version时,我的laravel版本是8.83.1
wqsoz72f

wqsoz72f3#

我运行了 composer 更新,它修复了一些东西

ffx8fchx

ffx8fchx4#

当我把php版本从7升级到8时也遇到了同样的问题,我把“laravel/framework”升级到“^8.75”,然后运行composer update。

vfhzx4xs

vfhzx4xs5#

我有同样的问题,由于laravel/php版本,我使用的是laravel 6.X LTS和php 8.1这是不兼容的,因为你可以在这里检查https://laravel.com/docs/9.x/releases,所以你有两个选择要么升级你的laravel或降级你的php,我的情况下,我使用宅基地&流浪汉,所以在您的sites条目您的家园.yaml你可以做一些像

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

或者任何你想用的php版本,运行vagrant reload --provision

jaxagkaj

jaxagkaj6#

当我尝试在php 8.1上运行Laravel 7.3时,我得到了同样的错误
对我来说,我有2版本的php安装在我的电脑上,php-7.4 and php-8.1.
当我检查终端上的php版本时,使用php --version,终端显示我使用的是php 7.4
所以我以为laravel用的是php 7.4,但事实并非如此,不知何故,网络服务器(nginx)被重定向到php 8.1
要确定使用的是哪个php版本,请使用内置的phpinfo()方法。

  • 从您的Laravel项目备份index.php
  • 然后删除index.php文件中的所有内容

在index.php文件中添加以下内容

<?php
   phpinfo();
?>

然后试着访问你的Laravel项目。那会给予你php信息页面,其中包括你的Laravel项目实际使用的php版本的信息。
当我在macOS Big Sur上使用自制程序时,我使用了这些命令来停止php8.1

brew services stop php@8.1
brew unlink php@8.1

然后我开始使用php 7.4

brew services start php@7.4
brew link php@7.4

For more info on switching php versions

xwmevbvl

xwmevbvl7#

查找文件并添加方法头:

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

DocumentationExample

wr98u20j

wr98u20j8#

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

相关问题