简体   繁体   中英

Running Laravel on Apple M1

I am installing Laravel on my Macbook Air M1, however, I am running into issues. The PHP version is PHP 8.1.0-dev and Composer version is 2.0.13. When I run:

$ composer create-project laravel/laravel example-app

I get this error message:

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].

Your error message seems to be an error generated Composer. The documentation for composer seems to imply that any version >= 5.3.2 is sufficient src . However, with PHP 8.1 not even being in Alpha until June , I should imagine it's safe to say there will not be official support for this for some time.

I did do a quick search for your error and got this article which states that one of the breaking changes that 8.1 introduces is passing null to a function that is not nullable. Official PHP Docs for strpos() indicate that none of the 3 arguments in strpos() are nullable, and thus what was 'allowed' in previous versions due to scalar types is no longer allowed for internal functions in 8.1, so you'll likely need to wait for Composer to officially support 8.1.

Even if you do fix Composer you're still using an unsupported version of PHP for Laravel. From their git the composer.json file specifies

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

So PHP 8.1 does not meet the requirement of PHP 8.0.x which is what the ^8.0 spec states. So you're likely to have unsupported errors when you do get that far.


The easiest, and safest, solution to fix all the above errors is to stick with PHP 8.x, unless there is a solid reason to be using PHP 8.1.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM