You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Unable to run php / composer etc in relation ot a XAMPP installation through MacOs Terminal

Hello, I have recently purchase a new mac running monterey and commenced setting up my local installation of XAMPP for Mac (running php 8.1.6). Followed the instructions per the website and XAMPP has been installed successfully. The local server and all that works. The issue / concern resides when trying to run either php and or composer update commands via terminal. If i try to run any php command and or composer update command eg. php composer update or php test.php i receive the following error -


zsh: command not found: php


I am finding this very strange since i have installed php via the XAMPP package. Additionally, should i go directly to the htdocs folder and run the same file "test.php" it works fine. Or if i update composer dependencies within the development IDE in this case PhpStorm it all works fine.


I double checked my previous install on my pc as well as my old mac and it all works fine. Has something changed with Monterey and if so is there anyone who can assist to get Terminal to recongise php commands etc?


Please note the error still occurs when i try to run the same script command with sudo prefix.


Many thanks



Posted on Sep 12, 2022 4:12 AM

Reply
Question marked as Top-ranking reply

Posted on Sep 12, 2022 4:53 AM

It is always good to get inspiration after you post a question. Ended up checking some old linux sources.

Have managed to mimic how it worked particularly on my pc by doing the following.


Installing the composer.phar into the following director usr/local/bin/composer

This will enable the composer commands to be executed via the following php command

php composer/composer.phar update


In order to get the php command to operate as expect need to bind php commands to the xampp bin/php executable. I achieved this by doing the following

sudo ln -s /Applications/xampp/xamppfiles/bin/php /usr/local/bin/php


please ensure to update the initial directory to how you have installed it on your mac system


to test that it has worked run the following command php -v into terminal

please make sure that your terminal directory is that of your htdocs or dev site folder


should this work you should receive a some php version text

For example PHP 8.1.6 (cli) ......... etc


I hope this helps.


As would should there be any issues with the above should people have a better alternative please let me know.

Got to this through lots of trial and error.


Cheers





Similar questions

1 reply
Question marked as Top-ranking reply

Sep 12, 2022 4:53 AM in response to brricey

It is always good to get inspiration after you post a question. Ended up checking some old linux sources.

Have managed to mimic how it worked particularly on my pc by doing the following.


Installing the composer.phar into the following director usr/local/bin/composer

This will enable the composer commands to be executed via the following php command

php composer/composer.phar update


In order to get the php command to operate as expect need to bind php commands to the xampp bin/php executable. I achieved this by doing the following

sudo ln -s /Applications/xampp/xamppfiles/bin/php /usr/local/bin/php


please ensure to update the initial directory to how you have installed it on your mac system


to test that it has worked run the following command php -v into terminal

please make sure that your terminal directory is that of your htdocs or dev site folder


should this work you should receive a some php version text

For example PHP 8.1.6 (cli) ......... etc


I hope this helps.


As would should there be any issues with the above should people have a better alternative please let me know.

Got to this through lots of trial and error.


Cheers





Unable to run php / composer etc in relation ot a XAMPP installation through MacOs Terminal

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.