【问题标题】:composer and laravel 7 not working with php 8.1 [closed]作曲家和 laravel 7 不适用于 php 8.1 [关闭]
【发布时间】:2022-01-22 07:38:55
【问题描述】:

今天我将 xampp 中的 php 更新为 8.1.0,之后所有 Laravel 项目都停止在 localhost 中。

所以,在将 composer.json 从更新到

"php": "^7.3|^8.0",

在运行 composer update 或任何 composer 命令后,我看到 composer 有这样的问题:

PHP Deprecated:  Return type of Symfony\Component\Console\Helper\HelperSet::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/console/Helper/HelperSet.php on line 112

Deprecated: Return type of Symfony\Component\Console\Helper\HelperSet::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/console/Helper/HelperSet.php on line 112
Deprecation Notice: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/Constraint.php:48
Deprecation Notice: Return type of Composer\Repository\ArrayRepository::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Repository/ArrayRepository.php:277
Deprecation Notice: Return type of Composer\Repository\ArrayRepository::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Repository/ArrayRepository.php:277
Deprecation Notice: Return type of Composer\Repository\ArrayRepository::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Repository/ArrayRepository.php:277
Deprecation Notice: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/Constraint.php:48
Deprecation Notice: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/Constraint.php:48
Deprecation Notice: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/Constraint.php:48

我该如何解决这个问题,因为作曲家有错误,我的所有项目都停止了。

【问题讨论】:

  • 为什么会这样? Laravel 7 不支持 PHP 8,并且是在它之前编写的。
  • 你在哪里看到 Laravel 7 兼容 PHP 8.1?
  • 好吧,如果你想使用 PHP 8,你需要使用兼容的 Laravel 版本。
  • @BrianThompson Laravel 7(和 6)仍受支持。规范 ^7.3|^8.0 表示它适用于 8.1。
  • 你需要更新作曲家;错误消息显然来自composer.phar。就做composer selfupdate

标签: php laravel composer-php php-8.1


【解决方案1】:

我在最新的 xampp 上遇到了同样的问题,我所做的只是回到 7.4.26,现在 6-7 的安装工作正常。

【讨论】:

  • 这只是一种解决方法。有什么解决办法吗?
猜你喜欢
  • 2020-12-02
  • 2021-01-03
  • 2020-03-30
  • 2013-08-13
  • 2021-06-14
  • 2014-11-08
  • 2012-10-06
  • 1970-01-01
  • 2019-09-05
相关资源
最近更新 更多