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?
Related
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.
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
been struggling to figure out why my install of php 7.3 is not being recognized.
I ran the following command in the terminal:
curl -s https://php-osx.liip.ch/install.sh | bash -s 7.3
I get a success message, but then when I try to verify the version, it says PHP 7.1.
I have updated my .bash_profile with the following:
export PATH=/usr/local/php5/bin:$PATH
Even after updating the path, I still get PHP 7.1 when I run php -v.
Any help would be greatly appreciated.
Try to replace "php5" with "php7" or "php" from your PATH
Remember to open new bash session (or source your profile source .bash_profile) after you changed PATH value from your .bash_profile
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.
I have installed xampp server in windows 7. I have already checked Browser its working.But I am trying to run the php -v command prompt. I receive the following error message.
´php´ is not recognized as an internal or external command,
operable program or batch file
This pops up if Windows doesnt know about php. To solve this you have to add the full path to the php.exe to your PATH-variable in windows.
After you restart the console php should be available.
Add the php folder to your path and restart cmd.
Use this command from the command line (use the path to the php.exe, it is usually under c:\xampp\php):
set PATH=%PATH%;C:\xampp\php
Add the full path to find the folder, for example:
c:\xampp\php\php.exe -v or c:\xampp\php\php.exe -version