Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
912 views
in Technique[技术] by (71.8m points)

macos - How composer check php version?

I just wondering how composer check which php to use when check for requirements. I use MacOS and in terminal type:

composer require phpunit/phpunit

the result is something like:

Problem 1
- phpunit/phpunit 5.0.4 requires php >=5.6 -> your PHP version (5.5.27) or "config.platform.php" value does not satisfy that requirement....

When I check php version:

php -v

The result is:

PHP 5.6.10 (cli) (built: Jun 12 2015 14:08:56) Copyright (c) 1997-2015 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans

Which is:

which php

php: aliased to /Applications/MAMP/bin/php/php5.6.10/bin/php

Can someone explain this. Thanks in advance!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Composer can tell you what version of PHP it's running on, if you specify debug verbosity -vvv.

I like to run it with the about command, since the output is relatively short.

composer -vvv about

Example output:

... Running 1.8.5 (2019-04-09 17:46:47) with PHP 7.3.5 on Darwin / 18.6.0 ...

Edit: This has gotten more interest than I expected, so here's a version with cleaner output:

composer -vvv about 2>&1 | grep "PHP"

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...