Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't I use 'php artisan' cmd in Laravel path (Win)

Tags:

php

cmd

laravel

I have tried to learn Laravel in Ubuntu and the command "php artisan' worked in the laravel folder path in the terminal.

I just start to do it in Win7, I typed "cd c:\wamp\www\myproject" in cmd.exe to change the path to the laravel folder (artisan file is in this folder).

After that I tried "php artisan" but I got this message "'php' is not recognized as an internal or external command, operable program or batch file."

Did I miss something? The command line showed there is C:\wamp\www\myproject>php artisan and I have double checked the file path is right.

Which step did I do wrong?

like image 396
Kai Avatar asked Dec 11 '22 16:12

Kai


1 Answers

The error is occurring because the windows command line doesn't know where to find the php.exe binary.

In Windows 7 click START and then type 'environment' into the start-menu search bar. Choose 'edit environment variables for your account'. In previous version of windows right-click My Computer then click properties. Go to advanced tab in the properties window and click the button on the bottom labelled, "Environment Variables."

Now, find the PATH environment variable and add the path to your PHP binary to it. Paths are delimited with semi-colons.

An example PATH variable may look like:

C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;D:\apps\Git\bin

Simply add the path to your PHP binary to the end, don't forget the intervening semi-colon. The path to my PHP binary is D:\work\apps\xampp177\php so my PATH variable will look like this:

C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;D:\apps\Git\bin;D:\work\apps\xampp177\php

Notice that the path doesn't contain php.exe. The path is only the folder which contains php.exe.

After the PATH has been saved, close your CLI, reopen it, and you should have no further problems using artisan.

like image 157
castis Avatar answered Dec 20 '22 08:12

castis