Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony "no PHP binaries detected"

Ive been just starting to learn Symfony PHP framework, and Ive run into some problems with its configuration.

When trying to create a new project with command line like so:

symfony new --full my_project

I kept getting a simple error message:

no PHP binaries detected

and no files were created in the current folder. I searched on the net, and found out that Symfony apparently isnt able to find the location of my php.exe, despite it already being set in my system variables. And there was no information about how to properly configure this in Symfony.

How do I fix this error?

like image 738
Kaitn13 Avatar asked Oct 04 '20 15:10

Kaitn13


2 Answers

Turns out Symfony already contains functions to autodetect installed PHP versions from system variables. The command to fix the Symfony configuration is this:

symfony local:php:refresh

My next attempt to create a new project work fine after that. Also, I suspect this error was the result of me installing PHP files after installing Symfony.

like image 73
Kaitn13 Avatar answered Oct 04 '22 09:10

Kaitn13


symfony local:php:refresh

doesn't always work. If your php is not in [/usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /usr/games /usr/local/games /snap/bin] and a few other locations (check with symfony local:php:list -vvv) then symfony won't find it.

I compiled my own PHP from source and installed versions 7.4.20 and 8.0.7 in /home/username/php/7.4 and /home/username/php/8.0. If I want to use my PHP 8.0.7, then I have to make a symlink because updating the $PATH doesn't help.

sudo ln -s /home/username/php/8.0/bin/php /usr/local/bin/php

This works and symfony finds it.

like image 32
James Young Avatar answered Oct 04 '22 09:10

James Young