Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

zsh: command not found: php

I have been using php with mamp on mac for a year even with old versions of MacOS, since I installed MacOS Monterrey if I type php on the terminal I get a message:zsh: command not found: php

Using older versions of MacOS I have never had this problem.

How can I solve the problem?

like image 355
Alex Mikhajlovic Avatar asked Oct 31 '21 11:10

Alex Mikhajlovic


People also ask

How to run PHP on Mac?

Use the Built-In Apache Web Server to Run PHP on Mac We can use the command sudo apachectl start in the terminal to start the webserver. Then, typing the URL http://localhost/index.php where our PHP file is index. html will run the PHP file. The PHP file should be in the root directory to run.

Can zsh expand the ~ on path?

I think ZSH won't expand the ~ on PATH. Try this instead: Show activity on this post. Show activity on this post. The command export PATH="$HOME/.composer/vendor/bin:$PATH" will work, but only for your current terminal session.

Where is CHSH file in Linux?

Trevor did show that according to "dnf provides" the file "chsh" is in package "util-linux-user". Thanks a lot . It works! Really appreciate of that.

How do I run zsh with Laravel?

If you would like the path to always be available when zsh launches, add PATH="$HOME/.composer/vendor/bin:$PATH" to the bottom of your ~/.zshrc file. Run the zsh command or restart your terminal and laravel will be available in every session you start.

Why am I getting a print ERROR when printing from zshrc?

If you receive this error then there is issue with the path.You have to edit the .zshrc file and add this line view source print? view source print? view source print?


2 Answers

When I update MacOS Monterey, PHP was remove. I found this article it useful and solve this problem for me. https://wpbeaches.com/updating-to-php-versions-7-4-and-8-on-macos-12-monterey

Add the PHP formulae

brew tap shivammathur/php

Choose the PHP version – this example uses 7.4

brew install shivammathur/php/[email protected]

Link the PHP Version

brew link --overwrite --force [email protected]

Restart the Terminal

php -v
like image 161
PTucky Eagle Avatar answered Oct 16 '22 15:10

PTucky Eagle


I had the same issue after updating to Monterry. After some googling, I find out MacOS doesn't include PHP. You need Homebrew to install PHP again.

brew install php

https://daily-dev-tips.com/posts/installing-php-on-your-mac/

like image 57
MetalBearSolid Avatar answered Oct 16 '22 16:10

MetalBearSolid