DEV Community


Discussion on: The current state of local Laravel development

eduardonwa profile image
Eduardo Cookie Lifter

So you can switch PHP versions with a Valet command? Does that affect the libraries used by Composer on a given project? I often get the error of my PHP version not being compatible with the libraries used by Composer. Its a mess and its still unclear to me why it gets fixed, i dont fully understand it yet. Loved the article 👍

dakira profile image
Matthias Niess

That happens when you have different PHP versions in local and production. E.g. you have PHP8 on your local machine and PHP7.4 in production. When you run composer update, the composer.lock file is created for PHP8. When you run composer install in production, you can't install the dependencies, because they were calculated for your dev machine.

If your server e.g. still runs PHP 7.3, you can run this in your project:

composer config platform.php 7.3.*

It add a section to the composer.json adjusting the dependencies to PHP 7.3. When you run composer update, the composer.lock file will now only get dependencies compatible with your server PHP.