-
-
Notifications
You must be signed in to change notification settings - Fork 5
Lecture 5.1 Troubleshooting
When you run a command for a program in command line, it looks for the corresponding executable files using the directories listed in your PATH variable as a map. The PATH variable is one of many Environment Variables your computer uses.
Given this, when you add a new executable/program you wish to use via command line, you have to add its directory to your PATH variable.
To start, use this command to see what your PATH variable is currently set to:
echo $PATH
We need to add the PHP executable that comes with MAMP to the PATH variable. In order to do that:
-
Get the PHP executable path of MAMP by typing the following in your terminal or by following the MAMP path in the finder:
ls /Applications/MAMP/bin/php/
Check the listed output. As of this writing, the latest version of PHP my MAMP came installed with is php7.2.7. Any version >= 7.2 will meet our needs.
-
Change the
paths
file from the terminal by typing the following in the terminal:sudo nano /etc/paths
-
At the top of the
/etc/paths
file, add this line (replace the x with your version number)/Applications/MAMP/bin/php/php7.x.x/bin
-
Save your changes (
ctrl
+x
, theny
, then Enter) -
Close and restart Terminal. (This step is important! If you don't do this, your changes won't take effect)
-
Test it out and you should see output similar to the following (version # and dates will vary; the key thing is that the version number and path matches the one you configured above):
$ which php /Applications/MAMP/bin/php/php7.2.x/bin/php
$ php -v PHP 7.2.x (cli) (built: M D YYYY HH:MM:SS) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
To begin, use this command to see what your PATH variable is currently set to:
PATH
We need to add the PHP executable that comes with XAMPP to the PATH variable. In order to do that:
-
Goto My Computer > Properties (alternatively, you can get here by running
sysdm.cpl
from Command Line) -
Then, from the Properties screen, go to Advanced > Environment Variables > Path
-
You'll find
Path
under System variables. Select it and click Edit -
Then, add a new path and set it to
c:\xampp\php\
to the end (be sure to include the trailing backslash at the end). -
Ok/Save your changes.
-
Close and restart Cmder (This step is important! If you don't do this, your changes won't take effect)
-
Test it out:
$ where.exe php c:\xampp\php\php.exe
$ php -v PHP 7.1.8 (cli) (built: Aug 1 2017 21:10:46) ( ZTS MSVC14 (Visual C++ 2015) x86 ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies