I'm trying to use PHP through the terminal, but I can not, when I type which php
it returns /usr/bin/php
so I can not run PHP files, so it can not find the files.
I'm using XAMPP for MAC
I'm trying to use PHP through the terminal, but I can not, when I type which php
it returns /usr/bin/php
so I can not run PHP files, so it can not find the files.
I'm using XAMPP for MAC
At the root of your user folder, ~
, has a file named .bash_profile
. Add the following at the end of it:
export PATH="/applications/XAMPP/xamppfiles/bin:$PATH"
Save the file and restart the terminal. Now which php
should indicate the XAMPP php-cli.
Alternative # 1
To call an executable from a specific directory, just type the full path to it. Instead of
php meuscript.php
use like this:
/Applications/XAMPP/xamppfiles/bin/php meuscript.php
Alternative # 2
Navigating to the folder where PHP is from XAMPP, and running from there:
cd /Applications/XAMPP/xamppfiles/bin
php meuarquivo.php