I followed the instructions as per the Getting Started page (https://symfony.com/doc/current/setup.html).
So after running php -r "readfile('https://symfony.com/installer');"
I then had a file called symfony
in the root of my C drive.
I then moved this to be in my C:\wamp64\bin\php
folder.
Adding C:\wamp64\bin\php
to my Path and closing then reopening the console (to refresh the path, if I run echo %path%
I can see it has been added to the path). I then try running symfony
and I get the message that
'symfony' is not recognized as an internal or external command,
operable program or batch file.
.
I get the same message if I try running symfony
in the directory it exists in.
If I move to the directory containing symfony
and run php symfony
it works, but this fails when used in a directory that does not contain symfony
.
If I use GitBash and try running symfony
then it works as expected.
Why does the console not find symfony
on my Path and how can I add it to it so that it will find this correctly.
I am using Windows 10 and have WAMP installed.
You need to add a batch script to help windows along.
For the sake of completeness, here are all steps required, tested on Windows 10:
get the symfony
file php -r "readfile('https://symfony.com/installer');"
move the symfony
file to a directory of your choice, so in your case C:\wamp64\bin\php
- personally I made a dedicated folder for commands to avoid unintended programs being picked up on: C:\commands
make sure that directory, not the file, has been added to the PATH
At this point if you enter symfony
into the command prompt it will come up asking you what you want to execute the program with, so not much use.
To remedy this we need to help it along and tell windows what to do with the file - that is, have PHP run it.
We can achieve this using a batch script:
create a file called symfony.bat
, place it into the same directory as your symfony
file.
Open the batch script in a file editor and add the following code:
@ECHO OFF
php "%~dp0symfony" %*
Once saved the symfony
command should run correctly as Windows will now use the batch file whenever the command is entered.
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