I'm using Homestead to develop a site that will be on a server with PHP 7.0. I want to use .env
files, so I ran this Composer command:
composer require vlucas/phpdotenv
When I perused the file, composer.lock
, I noticed that a dependency, doctrine/annotations
, was requiring PHP 7.1.
I tried adding this to my composer.json
file:
"config": {
"platform": {
"php": "~7.0"
}
},
When I run composer update
, I get this error:
[UnexpectedValueException]
Invalid version string "~7.0"
I realize that this is because PHP 7.2 is the default version on Homestead. How do I run Composer with PHP 7.0 instead of PHP 7.2?
Executing which composer
will give you this output:
/usr/local/bin/composer
The Homestead documentation discusses the multiple PHP versions supported and how to call them from the command line for Artisan. Combining that with the composer path above allows you to do this:
php7.0 /usr/local/bin/composer update
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With