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
Related
I am trying to use composer to install a google client library, but cannot install composer or use php on the command line.
I am using php 8.0.8 with MAMP and it is working fine, so I know it is installed.
If I type php in the terminal, I receive the command not found message. Thinking it could be an environment variable, I have tried navigating to the php folder /Applications/MAMP/bin/php/php8.0.8/lib/php and tried the php command again, but still get the same error
I am using a Mac running Monterey
Change default Mac OS X PHP to MAMP's PHP Installation and Install Composer Package Management
Instructions to Change PHP Installation
First, Lets find out what version of PHP we're running (To find out if it's the default version).
To do that, Within the terminal, Fire this command:
which php
This should output the path to the default PHP install which comes preinstalled by Mac OS X, by default it has to be (Assuming you've not changed it before):
/usr/bin/php
Now, We just need to swap this over to the PHP that is installed with MAMP, which is located at /Applications/MAMP/bin/php/php5.4.10/bin (MAMP 2.1.3)
To do this, We need to edit the .bash_profile and add the MAMP version of PHP to the PATH variable.
Follow these simple steps:
Within the Terminal, run vim ~/.bash_profile
Type i and then paste the following at the top of the file:
export PATH=/Applications/MAMP/bin/php/php5.4.10/bin:$PATH
Hit ESC, Type :wq, and hit Enter
In Terminal, run source ~/.bash_profile
In Terminal, type in which php again and look for the updated string. If everything was successful, It should output the new path to MAMP PHP install.
In case it doesn't output the correct path, try closing the terminal window (exit fully) and open again, it should apply the changes (Restart in short).
Install Composer Package Management
Now you can fire the command to install the composer globally (So you can access it from anywhere):
$ curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
You can verify your installation worked by typing the following command within the Terminal:
composer
It'll show you the current version and a list of commands you can use if the installation was successful.
Original source
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?
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
when i run the following command in cygwin terminal
$ php -r "readfile('https://getcomposer.org/installer');" | php
!/usr/bin/env php
Some settings on your machine make Composer unable to work properly.
Make sure that you fix the issues listed below and run this script again:
The json extension is missing.
Install it or recompile php without --disable-json
The phar extension is missing.
Install it or recompile php without --disable-phar
The ctype extension is missing.
Install it or recompile php without --disable-ctype
above error facing , how to solve it, more i have already install xampp, composer_setup.exe , but i want to run composer with cygwin terminal. how to run it ?
A bit too late, but you can try to:
Copy composer.phar to cygwin/usr/bin
Create a new composer.bat file with:
#ECHO OFF
php "%~dp0composer.phar" %*
Then restart cygwin and retry
Additionaly, this can help:
Cygwin/Gitbash + composer = unknown command
I am trying to run a php file on a ubuntu linux server but get a 'command not found' error when i run "php file_name.php"
Searching online, i found an article that suggested I run "sudo aptitude install php5-cli" which I did and restarted apache afterwards but I still get this error.
How do I fix this?
Try this once,
Go to terminal.
whereis php
It will show where is php installed.
Export that path to environment variable using following command
export PATH=$PATH;/path/to/php's/bin directory
Then execute required file..
As follows,
php file_to_execute.php
first make sure that you've installed following packs:
php5
php5-cli
php-pear
like this:
sudo apt-get install php5 php5-cli php-pear
then make sure to configure php safely befor using it.
also make your php file executable ( chmod 700 )
Try the following step :
Open your cmd/console or press ctr+alt+t.
php5 /your/path/to/php_file_name.