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?
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.
Related
currently im trying to make backup and restore mysql database in my laravel project. I am using this laravel package https://github.com/backup-manager/laravel for backup package. i already follow the intructions, but when i am trying to backup my local database through command line (php artisan db:backup) in the last question, i got this message.
Dumping database and uploading...
[BackupManager\ShellProcessing\ShellProcessFailed]
'mysqldump' is not recognized as an internal or external command,
operable program or batch file.
I already googling it, and already put C:\xampp\mysql\bin to my windows env variables paths, but i still having this issue. if anybody know how to fix this, please tell me, i really appreciate it.
Laravel 5.1.x
It is because mysqldump.exe is not found in that location, the right path is given bellow
Open Command Prompt and type this
cd C:\Program Files (x86)\MySQL\MySQL Server 5.5\bin
Press Enter
then type
mysqldump.exe
or,
Directly open this directory "C:\Program Files (x86)\MySQL\MySQL Server 5.5\bin" and Press LEFT SHIFT KEY from keyboard and RIGHT CLICK on the Directory Window.
then type
mysqldump.exe
It will work 100% correctly
If you are using Xamp then:
Open your Xamp folder
Go to \mysql\bin find the mysqldump.exe
Go to your environment variables under System variable click on 'New'.
As 'variable name' put 'mysqldump'(without the quotes) and as 'variable value' put the path to your xamp\mysql\bin\mysqldump.exe this will make 'mysqldump' available as a global system alias.
Reminder: Make sure to restart your command-line interface.
It happened with me and I solved it by adding the following line at the top of the .bat file.
cd "C:\xampp\mysql\bin"
Please add C:\xampp\mysql\bin to this path at your user variables and system variables. If you are using a wamp server, add C:\wamp64\bin\mysql\mysql8.0.27\bin this path at your user and system variables.
Note: MySQL version path will change as per your installation.
On my side, I was using PowerShell and I had the same error message.
I had to go inside the directory of MySql. Mine was located in:
C:\Program Files\MySQL\MySQL Server 5.7\bin
Then I had to make sure that I had mysqldump.exe in the bin folder.
And then run this command:
./mysqldump.exe -u root -p yordbName > C:\MySqlDump\sakila.sql
It is late, but I will answer to this question for other people who have the same issue.
You need to add the mysqldump.exe runtime file path to your Windows environment variable. I am using Wamp, the path look like this "C:\wamp64\bin\mysql\mysqlx.x.xx\bin"
Close your command-line interface and try again, It should work.
I am using Xamp and the following step is working:
Copy the path "C:\xampp\mysql\bin"
Go to your environment variables under System variable click on 'Path' and add "New".
Put the path there then click ok.
Restart your command-line interface.
I have a problem in accessing the php command using command line.
I also created a PATH in my environment variables.
The PATH is like this
C:\wamp\bin\php\php5.5.12
Now the console output is this
C:\Users\Web4>php
'php' is not recognized as an internal or external command,
operable program or batch file.
I also restarted the PC and the command console still same effect. I also created a batch for this still same effect too.
SET PATH=%PATH%;C:\wamp\bin\php\php5.5.12
Is there some configuration other than this? I am using wampserver.
If you run echo %PATH% and it does not include the path to WAMP, then the problem is simply that you haven't set it properly in your environmental variables.
The setting is located here:
http://i.imgur.com/fy5LvRD.png
Edit the System Variables "Path" field and prepend your path to WAMP (obviously make sure you have the exact path to the folder where php.exe is located). Then click OK until all the settings dialogs are closed.
Once you change the path, you will need to close your CMD window and open a new one. The path changes don't take effect on any open CMD windows.
I have .phar file and i want to run it from anywhere with this command.
php file.phar --options
where file.phar is in C:\my-php-cli\file
That is not possible. For example, putting file.phar to C:\Windows\System32 and calling php file.phar --options from another directory like C:\Temp will produce
Could not open input file: file.phar
You have to create a small batch file next to your *.phar, e.g., run-file.bat with this contents:
#ECHO OFF
php %~dp0file.phar %*
Then, calling run-file will execute your file.phar.
For Windows 10 I found that you need a your-file.cmd to run the .phar file.
I was trying to get php-cs-fixer running so in my PHP directory i had the following:
PHP\
phpFixer\
php-cs-fixer.phar
php-cs-fixer.cmd
Contents of php-cs-fixer.cmd:
#php "%~dp0php-cs-fixer.phar" %*
verified it works by entering this in command line:
php-cs-fixer --version
PHP CS Fixer 2.14.0 Sunrise by Fabien Potencier and Dariusz Ruminski (b788ea0)
Hope that helps
You would need to add the folder containing file.phar to your path variable.
See this link for more information.
To make wp-cli.phar work,
Create wp.bat
Put the following in it:
#ECHO OFF
php %~dpn0.phar %*
%~dpn0: Is a placeholder for $0 (Linux users will understand).
The directory where you want to place wp.bat, make sure to add that path to the environtment variables.
Rename wp-cli.phar to wp.phar (should be the same as the name of the .bat file, i.e. wp.bat and wp.phar. It is better to have both in the same directory.
Open a new PowerShell window, and execute
wp --help
The above command will only work if you have PHP installed.
This is how you make .phar files work the way .bat or .vbs files work where you can run them directly or add them to your path and it will automatically run them through the appropriate interpreter (in this case PHP)
Add ;.PHAR to the end of your PATHEXT environment variable (searching "Edit the system environment variables" in the start menu should get you to the right place). This is a semicolon separated list of file extensions that will be run in the same command window rather than launching their own window.
Set the default program for .phar files to be php.exe. You can get to the settings for this by searching "Choose a default app for each type of file" in the start menu or by selecting "Try an app on this PC" > "Look for another app on this PC" in the dialogue that opens the first time you try to open a .phar file.
At this point you can run .phar files just like you would run a .bat file. You don't have to worry about what directory php.exe is in, but you do have to worry about what directory the .phar is in. If you want to make a particular .phar file available from any folder it needs to be inside a folder listed in your PATH. Either move the .phar to an existing folder in your PATH (like C:\Windows\system32) or add the folder containing the .phar to your PATH the same way you modified PATHEXT in step 1.
You have to close and re-open any cmd/powershell windows before environment variable changes go into effect.
Run your .phar file without putting php in front. If it is in your PATH you can optionally omit the .phar at the end as well. This is nice if you are using, for example, composer.phar. Once you set everything up and add it to your path, you can do things like composer --version from any directory.
I want to run a .php file in windows cmd.
I followed this (suggestion)
php is not recognized as an internal command (in Windows)
But it did not work.
I tried this command prompt: C:\Windows\system32> cd \myfolder
And within myfolder I did as follows:
C:..\myfolder> php file.php
but I get an error "php is not recognized as internal or external"
But when I try without php command like this; C:..\myfolder> file.php
it just opens in notepad, yet I want to run it in cmd. How can I do it?
If running Windows 10:
Open the start menu
Type path
Click Edit the system environment variables (usually, it's the top search result) and continue on step 6 below.
If on older Windows:
Show Desktop.
Right Click My Computer shortcut in the desktop.
Click Properties.
You should see a section of control Panel - Control Panel\System and Security\System.
Click Advanced System Settings on the Left menu.
Click Enviornment Variables towards the bottom of the System Properties window.
Select PATH in the user variables list.
Append your PHP Path (C:\myfolder\php) to your PATH variable, separated from the already existing string by a semi colon.
Click OK
Open your "cmd"
Type PATH, press enter
Make sure that you see your PHP folder among the list.
That should work.
Note: Make sure that your PHP folder has the php.exe. It should have the file type CLI. If you do not have the php.exe, go ahead and check the installation guidelines at - http://www.php.net/manual/en/install.windows.manual.php - and download the installation file from there.
you can for example: set your environment variable path with php.exe folder e.g c:\program files\php
create a script file in d:\ with filename as a.php
open cmd: go to d: drive using d: command
type following command
php -f a.php
you will see the output
You should declare Environment Variable for PHP in path, so you could use like this:
C:\Path\to\somewhere>php cli.php
You can do it like this
It seems your question is very much older. But I just saw it.
I searched(not in google) and found My Answer.
So I am writing its solution so that others may get help from it.
Here is my solution.
Unlike the other answers, you don't need to setup environments.
all you need is just to write php index.php if index.php is your file name.
then you will see that, the file compiled and showing it's desired output.
‘php.exe’ is not recognized as an internal or external command,
operable program or batch file.
Why does that error occur even though I've added PHP to my environment variables?
My environment variable PATH is shown below:
C:\Program Files\NVIDIA Corporation\PhysX\Common;C:\Program
Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files\PC
...............
Files\QTSystem\;A:\xampp\php\php.exe
I'm using Windows 7.
A:\xampp\php\php.exe
The PATH environment variable must contain paths only, not file names.
Make that
A:\xampp\php
it is very easy to do
You need to also add php.exe
Adding this path:
windows key + pause
click on Advance system settings
click Environment Variable
System variables part -> Path -> Edit and the add
C:\wamp\bin\php\php5.3.8;
close you cmd prompt if its open
It's Done!
I think you need to change it to A:\xampp\php\ and just leave it there, then it will search the directory for the file, also: have you tried calling just php instead of php.exe and check that the directory is correct.
View above screen shot for setup enviroment variable in window 7
Note:- After setup enviroment variable please restart you computer then its will work fine
Shouldn't the last part be: C:\xampp\php\ ? Unless you remapped your drives, A is the floppy disk. :)
Also, you need to specify the folder, not the exe file itself.
My case am Using Bitnami Ruby Stack apache Web server ,
Pressed Windows key + Pause/Break Button
Clicked advanced system settings
Click Environment Variables
Under System variables > edit PATH variable by adding C:\Bitnami\rubystack-1.9.3-24\php
Click Ok to close the Environment Variable window
Close your command prompt if open
*(Proceed to 7. to confirm if php is installed)
Press Windows Key + R button to open your cmd
Type php -v to view your php version
Set PHP as environment variable from System as below to run it from CMD
1)Windows key + Pause
2)Click on Advanced system settings
3)Now click on Environment Variables.. button
4)In system variable section search for Path and edit it as D:\wamp\bin\php\php5.3.13;(If one needs to append it to some already exits value then start path with;)
5)Now open CMD and run command PHP from any path where you don’t have PHP installed , in my case it’s C drive.
6)We can check above set Path from CMD using Path command also.
If you have installed WAMP server, then your path can vary. For example, I installed WAMP and the path to my php.exe turned out to be:
C:\wamp\bin\php\php5.5.12\php.exe
To make it work, I entered the following path in the PATH variable of the System Variables:
C:\wamp\bin\php\php5.5.12
Once done, I restarted command prompt and everything worked fine.
So the path can vary depending upon how you installed PHP. If you would like to install WAMP server and have it install other essential packages like PHPMyAdmin, etc. you may do so from: wampserver.com
In my case, environment path is C:\ProgramData\Drush\;C:\Program Files (x86)\Drush\Php; and it works for me.
If I simply add C:\xampp\php\ dint work for me.
I hope if someone facing this issue can try this suggestion.
This happened to me and I found why.
Xampp can't run properly depending on your UAC settings.
Try to do this:
Log in as administrator (running cmd.exe as administrator isn't enough)
Execute cmd.exe or equivalent
type php -version