我正在我的Macbook Air M1上安装Laravel,但是,我遇到了一些问题。PHP版本为PHP8.1.0dev,Composer版本为2.0.13。当我跑步时:
$ composer create-project laravel/laravel example-app我收到以下错误消息:
Deprecation Notice: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated in phar:///opt/homebrew/Cellar/composer/2.0.13/bin/composer/src/Composer/DependencyResolver/SolverProblemsException.php:111
Problem 1
- phpunit/phpunit[9.3.3, ..., 9.4.0] require phpspec/prophecy ^1.11.1 -> satisfiable by phpspec/prophecy[1.11.1, ..., 1.13.0].
- phpspec/prophecy 1.11.x-dev is an alias of phpspec/prophecy dev-master and thus requires it to be installed too.
- phpunit/phpunit[9.4.1, ..., 9.5.x-dev] require phpspec/prophecy ^1.12.1 -> satisfiable by phpspec/prophecy[1.12.1, 1.12.2, 1.13.0].
- phpspec/prophecy[dev-master, 1.12.0, ..., 1.13.0] require php ^7.2 || ~8.0, <8.1 -> your php version (8.1.0-dev) does not satisfy that requirement.
- phpspec/prophecy 1.11.1 requires php ^7.2 -> your php version (8.1.0-dev) does not satisfy that requirement.
- Root composer.json requires phpunit/phpunit ^9.3.3 -> satisfiable by phpunit/phpunit[9.3.3, ..., 9.5.x-dev].发布于 2021-05-20 23:12:44
您的错误消息似乎是一个错误生成的编写器。composer的文档似乎意味着任何版本的>= 5.3.2都是足够的src。但是,PHP8.1甚至在Alpha之前都不存在。,我可以肯定地说,在一段时间内,官方不会支持这一点。
我对您的错误进行了快速搜索,得到了这篇文章,它指出8.1引入的一个重大更改是将null传递给一个不可为空的函数。针对strpos()的官方PHP表明,strpos()中的3种参数都不能为空,因此以前版本中由于标量类型而“允许”的内容不再允许用于8.1中的内部函数,因此您可能需要等待Composer正式支持8.1。
即使您做了fix Composer,您仍然在为Laravel使用不受支持的PHP版本。在它们的git中,composer.json文件指定
"php": "^7.3|^8.0",因此PHP8.1不符合PHP8.0.x的要求,而这正是^8.0规范所规定的。所以,当你走那么远的时候,你可能会有不受支持的错误。
修复上述所有错误的最简单、最安全的解决方案是坚持使用PHP8.x,除非有充分的理由使用PHP8.1。
https://stackoverflow.com/questions/67628637
复制相似问题