To use XAMPP’s PHP as default PHP in your command line to execute PHP commands from
your command line/prompt you have to just follow the simple steps mentioned below:
in this tutorial I used UBUNTU as my OS
Open your terminal and open .bashrc file by following command:
sudo gedit ~/.bashrc
If you don’t use GUI or gedit not installed then you can use vim instead of gedit like following
sudo vim ~/.bashrc
and just you have to add the following line at the end of your .bashrc file.
export PATH=/opt/lampp/bin:$PATH
Now restart your terminal and you are done!
Now type php -v
to verify that it’s working. this php -v command will show you the
PHP version used in your command line. Happy PHP’ing.