MAMP and PHP on Terminal - php

So I have installed MAMP and I am using PHP, however I also used Terminal with PHP as well. Now for some reason Terminal is not working with PHP anymore, for example:
Terminal / PHP command not found
So basically I can not work with anything at the moment. I have also simplified .bashrc and .bash_profile.
Terminal and PHP not found
Thanks. mac-machine

cd ~ && nano .zshrc
Add the path of php in .zshrc like:
export PATH=/Applications/MAMP/bin/php/php8.0.8/bin:$PATH
Then run source .zshrc and run php -v to confirm path setup

The problem is working with PHP command line is not found with ZSH, it gets a message: zsh: command not found: php.
So working with older BASH instead of ZSH it works fine.

Related

zsh: command not found: php with xampp

I installed xampp on Ubuntu 22.04.
Running .php files is ok.
Example directory like that.
/opt/lampp/htdocs//helloworld.php
That file worked and run in browser. But when I run php command on terminal, it gave me this error.
error image
I thought this error happened because zsh shell.So I add .zshrc file to this.
export PATH=<path-to-lampp>/bin/php/<php_version>/bin:$PATH
Still not working. Please help.
I got the solution. The problem is need to give symbol link i think.
My solution: run this command in terminal
$ sudo ln -s /opt/lampp/bin/php /usr/bin/php
Check if your PHP path is right, you should output PHP version by {PHP path} -v.
Do you source /.zshrc after changing the .zshrc file?

bash: php: command not found in VSC only

php -v works in individual terminals, but do not work in Visual Studio Code Terminal.
I tried php -v in Git Bash and Command Prompt in Windows, and all worked.
So I tried in VSC where I set default shell to Git Bash, but it shows error with bash: php: command not found
(I added php bin path to Path)
Terminal at VSC do not get PATH variable?
I got the same problem... My problem was in VSC FlatPack version available in the Software Manager in Mint 18.3. I uninstalled it and got the original version on https://code.visualstudio.com See more at: https://github.com/microsoft/vscode/issues/44646

PhpStorm + XAMPP not showing latest PHP version in command line

I am using OSX running on El Capitan and setting up PhpStorm and the Laravel environment has been a nightmare. I created a project setting up Composer and created it with laravel/laravel from the options menu.
As you can see in the screen shot, the PHP version says 5.6.31.. but if I type php -v in the command line. It gives me php 5.5 (as shown in the bottom left)
If I type php -v in the terminal I also get php 5.6.
which php returns me /usr/local/bin/php
I originally had a problem where PHP would not upgrade to 5.6.. but I managed to solve this with homebrew.
And if I use terminal and cd into the folder to run artisan key:generate and config:clear .. I am able to get the Laravel homepage to load (but typing this from the PhpStorm command line does not work).
My understanding is that the command line is pointing to the directory of PHP that came with my Mac? So how do I point it to the upgraded version? Or is the problem something else?
I think this is a strange problem and already a few people I have asked have not been able to solve it (also setting this up is all very new to me).
what I did is to set an alias on my ~/.bashrc to point php command to point to /Applications/XAMPP/bin/php
e.g. alias php="/Applications/XAMPP/bin/php"
in your case, you can use your XAMPP's full path to your php binary file as you might have different installation paths.
You should be able to add:
export PATH=/Applications/XAMPP/xamppfiles/bin/php5.6.31:$PATH
to your ~/.bash_profile (assuming you're running a bash shell). Then just run source ~/.bash_profile and it should all work.

Phalcon devtools not working

I'm attempting to install Phalcon Dev Tools on OSX. I have Phalcon installed and it works fine.
I've followed the instructions from here: http://docs.phalconphp.com/en/latest/reference/mactools.html
When I run the command phalcon in the terminal I get the following output:
Phalcon Developer Tools Installer
Make sure phalcon.sh is in the same dir as phalcon.php and that you are running this with sudo or as root.
Installing Devtools...
Working dir is: /Users/me/phalcon-tools
Done. Devtools installed!
Now how do I use the devtools? When I enter phalcon commands the output is exactly the same as above, and continues to tell me that it's installed.
Am I missing something here?
I noticed in the phalcon.sh script, at the end it had:
if check_install; then
php "$PTOOLSPATH/phalcon.php" $*
fi
So, if check_install passes, run phalcon.php. I've tried to run this script manually and nothing happens at the terminal.
$PTOOLSPATH is defined. I confirmed this using echo $PTOOLSPATH.
My /usr/bin/env php is correct and points to MAMP's PHP. I have Phalcon installed using MAMP at the moment. My PHP is correct:
which php
/Applications/MAMP/bin/php/php5.5.23/bin/php
Inspecting the phalcon.php script, and using xdebug, I detected the issue to be lying here:
if (!extension_loaded('phalcon')) {
throw new Exception(
sprintf(
"Phalcon extension isn't installed, follow these instructions to install it: %s",
Script::DOC_INSTALL_URL
)
);
}
So the Phalcon extension isn't loaded. Not sure why it's not printing the output of the exception in the terminal. But, PHP's error log is showing:
[21-May-2015 22:37:48 Europe/Berlin] PHP Fatal error: Class 'Phalcon\Script' not found in /Users/me/phalcon-tools/phalcon.php on line 41
Now I'm stumped.
Edit:
Running php -m showed me Phalcon isn't installed. Which is odd, because I am using Phalcon in my web application, and it works fine. As you can see, I've loaded the extension in the php.ini.
The PHP version I'm using is:
PHP 5.5.23 (cli) (built: Apr 9 2015 19:29:27)
As you can see, Phalcon is in the correct directory:
ls /Applications/MAMP/bin/php/php5.5.23/lib/php/extensions/no-debug-non-zts-20121212
apcu.so
imagick.so
phalcon.so
...
And as you can see from phpinfo() it's installed ...
The following commands both give different results too:
Shows Phalcon as installed:
echo "<?php phpinfo(); ?>" | php > phpinfo.txt && cat phpinfo.txt | grep phalcon
Shows Phalcon not installed:
php -m
Any ideas?
After trying a lot, I found out that the code shown in the reference is wrong:
ln -s ~/phalcon-tools/phalcon.sh ~/phalcon-tools/phalcon
chmod +x ~/phalcon-tools/phalcon
The proper way can be found in the github repo:
ln -s ~/phalcon-devtools/phalcon.php /usr/bin/phalcon
chmod ugo+x /usr/bin/phalcon
Basically, the link shouldn't be the script but the php file. Fixing that, I could run the dev tool properly.
I have the same problem with you. and I solved it as long as I add this two line into my ~/.bash_profile file.
export PATH=$PATH:/Users/scott/phalcon-tools
export PTOOLSPATH=/Users/scott/phalcon-tools
At first, I only add the first line into .bash_profile, and I got the same information with you.
May be in command line ini file phalcon is not installed so it is throwing error.
just type this command in terminal .
php --ini
then check the output the interesting line is
Loaded Configuration File: /etc/php5/cli/php.ini
now try to check that
phalcon.so
is loaded there as well or not.
as for web and cli there are different phalcon.so file is provided so we need to inlcude "phalcon.so" in both files.
so phalcon.so is included in your web php.ini so its running smooth there and not it command line i guess.

Setting PHP variable path for Cygwin

I am having a lot of difficulty routing PHP to cygwin.
My goal is simply to run the following PHP test command successfully:
php -v
I'm currently getting the following error: -bash: php: command not found
This is what I tried in the .bash_profile document:
PATH = $PATH:/xampp/php
export PATH
I am using xampp and my php.exe is in the following path C:/xampp/php/php.exe, also I noticed there isn't a bin directory in my php directory. There is a bin directory in C:/xampp/apache perhaps this is the one I should link to? I tried this as well with no success.
In Cygwin you windows C drive is mounted to /cygdrive/c/ so if you wanted to add C:/xampp/php/ to your path, then you should add the following to your .bashrc:
export PATH=$PATH:/cygdrive/c/xampp/php
What #flungo wrote was absolutely correct:
I have to add this line to C:\cygwin64\etc\bash.bashrc in order for each new cygwin terminal to have the correct $PATH
export PATH=$PATH:/cygdrive/c/xampp/php

Categories