How to enable newer version of php to be default? - php

I'm trying to understand how to update my php version in my machine. On the CMD I tried getting the version as shown below. I believe this version was installed via XAMPP but now I have uninstalled this program. When I try to get the version again in the CMD it remains 7.2.26!
C:\Users\name>php -v
PHP 7.2.26 (cli) (built: Dec 17 2019 15:29:44) ( NTS MSVC15 (Visual C++ 2017) x64 )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
I have downloaded a new version, hoping that it would solve it (php v.7.4.8) and added it in C:\php directory (it is the only version available) but the cmd will still return version 7.2.26!
Note that when I open the C:\php\php.exe and run phpinfo(); the version is 7.4.8.
My question is how to completely remove php 7.2.26 from my machine. I cannot locate where it is installed!

Change System Path variable of your computer which still points to the directory in which old version is installed.
Goto My Computer
Right Click, choose Properties
Select Advance System Settings
Goto Advanced tab
Click Environment Variables.
Double click on Path in the System Variables list
Remove old folder location from the Variable Value field and add new location.
Save Settings by clicking OKs

Related

Configure CLI interpreter for PhpStorm on Mac

I have installed PHP from brew and it works just fine in VSCode, but in PhpStorm I am not able to configure the interpreter in order to debug my PHP code.
In the configuration file, it says "PHP not installed" with a red icon, and the executable path is empty.
I am trying to debug just code, not a web page, so there is no need of Apache Server or other for now.
When executing php -v on terminal, I get:
PHP 8.0.17 (cli) (built: Apr 5 2022 22:43:04) ( NTS ) Copyright (c)
The PHP Group Zend Engine v4.0.17, Copyright (c) Zend Technologies
with Zend OPcache v8.0.17, Copyright (c), by Zend Technologies
which tells me that this installed correctly.
As per PhpStorm documentation you have to point to PHP executable there (which means: provide the full path). Just having php may not be enough.
Open your OS terminal and type which php (or it could be where php; this depends on the OS used). It will show the full path to the executable that gets executed when you run php in that terminal.
If you have more than one PHP version installed and want to use non-default PHP installation/version then use the path for that specific version.
Copy that full path from there (if there are more than one path then use the top most or the most desired one) and use it in the "PHP executable" field of the PHP Interpreters screen in PhpStorm.

Symfony only detects lowest php version

I installed Wamp64, comes with 3 versions of php 5.6, 7.0 and 7.1
When I try to create a new symphony project I receive this error:
Could not find package symfony/skeleton with stability stable in a version > installable using your PHP version 5.6.31.
Obviously I need to activate php7 which I did, I restarted wamp services(apache ...etc) and I still get the same error. Please see attached image
Your PHP path probably points to the bad PHP version.
Try to type
php -v
If the version is not good you can change it by changing your path by typing, environment variable in your Windows search bar.
After that edit the value of the var Path and add the PHP bin folder
For me :
C:\PHP\bin\
And that's all
(Try to learn docker or install your development environment manually and use PHP built-in server to run your project, wamp is good when you start but you don't know how all work and this is bad :( )
i have same issue :
php --version
PHP 7.3.9 (cli) (built: Feb 17 2020 12:46:14) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.9, Copyright (c) 1998-2018 Zend Technologies
But symfony always output :
Could not find package symfony/website-skeleton with stability stable in a
version installable using your PHP version 5.6.30.

How to change preloaded php version to MAMP in Mac/OSX

I am using Mac/OSX for the first time and I have installed MAMP and set PHP Standard Version as 7.1.6 but when I have run php -v command in the terminal I am getting below details:
PHP 5.6.30 (cli) (built: Feb 7 2017 16:18:37)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
Can you please guide how to use 7.1.6 version instead of 5.6.30.
Thanks.
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/php7.1.6/bin
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/php7.1.6/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.

error upgrading php in mac

I am running OSX El Capitan (version 10.11.6).
I had php 5.5 installed.
Phpunit requires php5.6 and more so I tried to upgrade my php to 5.6. I couldn't do it so I gave php7 a try.
I followed these guides:
https://coolestguidesontheplanet.com/upgrade-php-on-osx/
https://php-osx.liip.ch/
Mac upgraded PHP to 5.6, but CLI php -v get 5.3.28?
My current output with php -v is :
PHP 7.0.12 (cli) (built: Nov 1 2016 10:21:11) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.12, Copyright (c) 1999-2016, by Zend Technologies
with Xdebug v2.4.1, Copyright (c) 2002-2016, by Derick Rethans
Funny thing, my output with a phpinfo(); when called from somewhere inside a Symfony project, is still PHP Version 5.5.36
Any ideas??
Terminal uses a different PHP than a HTTP server in browser. You can check what PHP you're using in CLI (command line interface) by this terminal command:
$ which php
I don't know if you use any AMP stack (like MAMP). They include their own PHP, so you need to update them in order to have a different PHP version in browser.
Maybe you can use this trick to determine what PHP versions you use in browser / CLI: Find the php.ini path in your phpinfo() output and compare it with this terminal command:
$ php -i | grep php.ini
It's always a good idea to use the debug URL to troubleshoot your Symfony projects; to use this, simply append:
app_dev.php
For example if your route was like http://myhome/, then you would use:
http://myhome/app_dev.php
Then on the bottom of your browser you will have the Symfony debug bar. In the bottom right corner, the version of Symofny is shown, an if you move your mouse over it, you will see the version of PHP; plus also a link to "View phpinfo()". You can click on it to view the full PHP information, including where the PHP file is located.
The PHP config file used (shown on the phpinfo() page) is shown by:
Loaded Configuration File
Hope that helps!

Two php version on mac, can i fix it?

I have a configuration problem about my php installation on my mac os x 10.9.2
If i do
php --version
on my terminal i get following output:
PHP 5.3.27 (cli) (built: Dec 4 2013 06:25:36)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies
while if i try to check php version via phpinfo(), i get following
PHP Version 5.4.24
so i have two php different version installed, 5.3.27 for cli mode e 5.4.24 on server side.
Also if i try to change configuration in php.ini, at path that i see on phpinfo() response (/private/etc/php.ini), after restart apache, i don't see nothing change; so i think that php.ini maybe is in another place.
How can i do to fix my php installation to have only one php version?
If you want it 5.4 on the CLI also, try moving the one at /opt/local/bin/php out of $PATH.
Normally php lives at /usr/bin/php, so it should find that one when you move the one at /opt/local/bin/php out of $PATH. Maybe echo $PATH shows /opt/local/bin/ before /usr/bin/ for you?

Categories