37

I am trying to install and setup Laravel 4 through the Git Shell using this tutorial:

It all seems to be working until I have to run php artisan key:generate at which point it gives me the error:

php : The term 'php' is not recognized as the name of a cmdlet, function, script file, or operable program

I have hunted around and am not sure how to go about setting this up so it recognizes PHP.

Does anyone have any ideas or know of a thorough tutorial to get Laravel 4 setup?

Antonio Carlos Ribeiro
  • 86,191
  • 22
  • 213
  • 204
Chris
  • 889
  • 4
  • 14
  • 21
  • @AmalMurali I have WAMP installed. Maybe I need to make sure the Laraval installation is within the WWW directory of WAMP? – Chris Oct 01 '13 at 20:12
  • Does this answer your question? ['' is not recognized as an internal or external command, operable program or batch file](https://stackoverflow.com/questions/48321639/is-not-recognized-as-an-internal-or-external-command-operable-program-or-bat) – SuperStormer Aug 31 '21 at 19:16

4 Answers4

82

Try adding your PHP.exe's folder to your System PATH variables, so PHP can be accessed via terminal.

For example; C:\wamp\bin\php\php5.4.3

To add new PATH variable, follow this:

  1. Right click on My Computer, select Properties
  2. Select Advanced System Settings
  3. In the System Properties window click the Environment Variables button.
  4. Select System Variables -> PATH and click Edit.
  5. Enter the folder where your PHP.exe is located.

If you did this correctly, restart your terminal and type php --version to check if it works.

Note: Don't forget to seperate paths by using ; seperator.

Aristona
  • 8,611
  • 9
  • 54
  • 80
  • How specifically can I add the `PHP.exe` folder to my PATH variables? I am still new to console programming. – Chris Oct 01 '13 at 20:16
  • The error is gone now, but I have another error in it's place, do you know of any good laravel 4 tutorials? – Chris Oct 01 '13 at 20:31
  • 1
    @Chris What error? You can install Laravel via `composer` if you want, and refer to the documentation in Laravel's website. http://four.laravel.com/#install-laravel – Aristona Oct 01 '13 at 20:31
  • On the step where it asks me to input `php artisan key:generate` it gives me a "warning failed to open stream: no such file in directory" in the autoload.php in my project. and that becomes a fatal error below it. – Chris Oct 01 '13 at 20:35
  • Did you change to the root folder before executing it? `cd C:/wamp/www/laravelFolder` – Aristona Oct 01 '13 at 20:36
  • I believe so, but am not sure. Is there a way for me to put a screenshot of it up for you to see? – Chris Oct 01 '13 at 20:38
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/38453/discussion-between-aristona-and-chris) – Aristona Oct 01 '13 at 20:38
1

If Aristona answer doesn't work again check path, you should add variable like this:

C:\wamp\bin\php\[var]

Where [var] is folder where you have php.exe, not specific file.

DON'T do it like this:

C:\wamp\bin\php\php.exe

Malak
  • 336
  • 2
  • 13
-1

Try adding your PHP.exe's folder to your System PATH variables, so PHP can be accessed via terminal.

  • 1
    Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 22 '22 at 12:09
-1

just install xamp and add path of php folder to system environment variables, will solve all problems

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 31 '23 at 14:11