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?
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.
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.
Follow below steps:
Step 1: download & Install xampp in your system
Step 2: open the xampp folder.
find php folder and hit enter
Step 3: copy the path and paste in your system environment
Step 4 : run
php -v
you are good to go!
Related
I came from frontend stack so I can misanderstand something when I'm learning symfony3.
I downloaded Symfony according to documentation with:
php -r "readfile('https://symfony.com/installer');" > symfony
To make php command available i added some values to the enviroment PATH variable (according to this tutorial: https://seiler.it/installing-symfony-framework-into-xampp-for-windows/ - step 2.3) like this:
c:\xampp\mysql\bin;c:\xampp\php;c:\xampp\php\PEAR;C:\xampp\php\symfony
As you see I'm using xampp for PHP development. I added that last, because i copied that downloaded symfony file to c:\xampp\php\symfony directory.
OK, now if i want to use symfony command, like
symfony new project
I need to go to directory where there is that symfony file and add 'php' before, like
php symfony new project
Because simple 'symfony new project' doesn't work (error msg tells about that command isn't known by Windows). How can i fix it?
In frontend there is something like npm (node package manager) with which you can install library/tool locally in directory or globally (to run it in terminal from any place on the computer). Is there is any equivalent in PHP development? I tried to install this by pear (from mentioned tutorial in step 7), but it installed me symfony 1.x version (and error of running that command was that there is no task like 'new') and i want to learn 3, not 1.
I tried to get composer, but i don't see where can i install there symfony globally.
So, how to run symfony globally? What am I missing?
From this doc:
In Windows, move the symfony file to a directory that's included in the PATH environment variable to create the global command or move it to any other directory convenient for you
idea
Install and use Git Bash. Gives you more futures then the windows CLI.
Performance
To run a ten times more fast environment for Symfony i prefer a Linux OS.
I am trying to install Symfony on CentOS Linux wih PHP 5.6 and cPanel installed.
When I run composer require symfony/assetic-bundle , once adding bundle to the AppKernelphp, symfony (app/console too) stops working and keeps logging this error:
[10-Jun-2016 22:00:57 UTC] PHP Fatal error: Class 'Symfony\Bundle\AsseticBundle\AsseticBundle' not found in /home/avid24/public_html/app/AppKernel.php on line 19
After checking the vendor directory, turns out that composer has downloaded a single compressed file with a random name, I could extract it with unzip. but problem still exists!
This environment works properly on windows and I could easily update symfony and its components using composer.
Any help? Anyone with the same experience ?
Well, I eventually figured out the problem!
I enabled suhosin extension which prevents the composer and other similar command prompt php scripts from a proper execution.
As a temporary solution I copied php.ini and disabled unnecessary extensions and put it next to my project and call composer this way
$php -c ../composer-php.ini ~/composer ......
I'll create a script to make the life easier
I didn't find any resource which describes coexistence of composer and suhosin extension, so I'm not sure if this is the ultimate solution but the root cause is identified.
If anybody makes workaround this subject I'd be more than happy to know about it.
I am Using my own Machine Kali Linux 2.0 Debian x64 . Now, i have Installed Laravel in my directory structure like
/opt/lampp/htdocs/learning-larvel/
Inside the Learning-laravel folder i have Installed my Laravel files, and also i installed composer. So when i go to http://127.0.0.1/learning-laravel/public . I see a See a White Screen and in Between it is written "Laravel 5", which means the Laravel GUI Setup is fine.
Now, to create a new file for Laravel, when i open my Terminal and type
laravel new xyz
then it gives me a error which says bash: laravel: command not found
Now, how can i fix the error.. I have researched about it by setting PATH to bashrc. But i am not getting it fixed right. Additionally when i type in my command composer -version then also it says bash: composer: command not found but i have Installed composer on the folder learning-laravel itself.
I could also see files like composer.phar there in /opt/lampp/htdocs/learning-larvel/
Any help would be extremely thankful.
As the composer official getting started page points out:
There are in short, two ways to install Composer. Locally as part of
your project, or globally as a system wide executable.
if you wanna do composer -- or laravel -- in command line, you wanna install them globally.
Check out the following links:
https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx
https://laravel.com/docs/4.2#install-laravel
I encountered the same problem. Apparently, the composer exists in path ~/.config/composer/vendor/bin when running as super user. Therefore, replacing the paths which were described above by this, and it should work. Hope it helps.
There are many documentation about how to install Zend Framework 2. But they are hard to understand. I've tried lot of guidance in the web. But still I couldn't install ZF2.
This might be a duplicate question. But I went through most of them and ended up with no success.
Can any one please give me the simple step by step installation guidance?
I'm using XAMPP on windows 7
Thanks a lot
EDIT: I'm getting this error
once you download skeleton application from Github you have run following command from command prompt
cd ZendSkeletonApplication
php composer.phar self-update
php composer.phar install
make sure you have php version greater than 5.3.3
php command not run directly in command prompt if path variable is not set
to check path variable set or not type php -v if command not recognized than please set environmental variable.
I have installed Symfony2 on a iis 7 server with PHP 5.3.21 and everything works ok ( the php, the symphony demo page ).
I try to create my own helloWorld, as the tutorial says :
php app/console generate:bundle
I go Start->Run->CMD and put that line of code and it gives me back this :
could not open input file : app/console
and before anyone asks i am in the project directory when i perform this command
I put the PHP directory to the System PATH but the problem persists.
Update: I ended up getting on a screen sharing program with #reza and discovered he had accidentally set his PATH variable to D:\php\wamp\bin\php\php5.3.10\php.exe rather than D:\php\wamp\bin\php\php5.3.10. Fixing this solved the problem.
Check this: I can't create bundle in symfony2
For newer versions of Symfony (2.4.x or newer) use this method on windows to resolve the problem:
Go to project directory e.g. d:/xampp/symfony2-project/ and open composer.json and place this under requires array "symfony/console": "2.4.*#dev". And save the file.
Open command-line and cd to project's directory.
Use this command to let download and install the dependencies: php path/to/composer.phar install. Remember you should be in your project's directory and path/to/composer.phar is the actual path to your composer.phar file.
Now you are all done, just use php bin/console generate:bundle --namespace=Test/PrintBundle --format=yml to test bundle system works.
If you are creating Symfony 2.5 project using command prompt then console file is not storing the app folder but it storing in the bin folder so you need to use bin folder instead of app folder (CODE is : php bin/console generate:bundle).