Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

DNABeast's avatar

Multiple Forge PHP versions don't reflect in code.

I've used Forge to install a version of PHP7.3 as CLI on my PHP7.2 server. Then I've got a project that has now been set under meta from php7.2 to 7.3

I've rebooted the server.

Now when I use Tinker and run phpversion() it returns

7.2.25-1+ubuntu16.04.1+deb.sury.org+1

If I try to deploy an app that was running on PHP 7.3 locally the composer.lock info tries to install 7.3 compatible stuff and fails with a 'Not compatible with 7.2' error

Where does each site set its PHP version info and how can I check that it's installed correctly?

0 likes
7 replies
DNABeast's avatar
DNABeast
OP
Best Answer
Level 27

The team at Forge put me on the right track.

I needed to update to environment variables. Instead of composer it's $FORGE_COMPOSER etc

$FORGE_COMPOSER install --no-interaction --prefer-dist --optimize-autoloader

( flock -w 10 9 || exit 1
echo 'Restarting FPM...'; sudo -S service $FORGE_PHP_FPM reload ) 9>/tmp/fpmlock

if [ -f artisan ]
then
$FORGE_PHP artisan migrate --force
fi

Also, I was testing using Tinkertool and tinker but what I failed to grasp was that to run those I was selecting the wrong version of php by running php artisan tinker from the command line.

2 likes
adampatterson's avatar

I updated from PHP 8.0 to 8.20 and my deployment is stuck in 8.0.

Everything says 8.2 from Nginx, PHP in the CLI, and composer, where would I manually update the PHP version and shouldn't Forge be doing this for me?

DNABeast's avatar

@adampatterson I may be misunderstanding your question but... In oder to upgrade PHP on your server you can go to the Server page and install the new PHP version CLI. Then I think you go to your site in the meta area and change the PHP version. I think you have to make sure your variables are setup in your launch script. And then maybe you have to run with your script to make sure it starts up the correct PHP version.

1 like
adampatterson's avatar

@DNABeast Nope, that was 100% correct. Maybe I missed that in the docs, but I didn't find that obvious at all!

Please or to participate in this conversation.