I'm trying to move my Project to a linux redhat server that uses Apache but the problem I'm facing there is that this Server has 2 different PHP versions installed.
Symfony (2.5.12) seems to look for the php executable at /usr/bin/php
by default but there is a 5.2 version installed, which is needed for other projects.
At /opt/rh/php55/root/usr/bin/php
is an installed 5.5 version of PHP that I want to use for symfony.
So how can I configure Symfony to use the php version that is installed at the custom path?
php-version file in a project directory, to change the PHP version per project. To undo or change, simply delete or overwrite the . php-version file. That's all there is to it!
Check PHP Version by Running PHP Code The simplest method to determine the PHP version running on your website is executing a PHP file that contains the following code: <? php echo 'PHP version: ' . phpversion();
I know this is old, but I had the same issue of Symfony using an older PHP version (7.1 in my case, the default with OSX Mojave) than I had installed. My $PATH
variable pointed to the newer 7.2 version and php -v
showed 7.2 and still Symfony used 7.1.
It looks like this was solved when I ran:
symfony local:php:list
It listed all the PHP versions on my system and it had 7.2 marked as default. After running this and executing symfony server:start
it was on 7.2.
The php:list
command also give useful instructions on setting a specific PHP version for a project:
To control the version used in a directory, create a
.php-version
file that contains the version number (e.g. 7.2 or 7.2.15). If you're using SymfonyCloud, the version can also be specified in the.symfony.cloud.yaml
file.
I had the same problem when I did symfony serve
.
First I ran symfony local:php:list
to know which version of php my project used.
Then I ran echo 7.4.9 > .php-version
(7.4.9 is the latest php version I downloaded) to switch the php version of my project.
It works fine for me.
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