How do i update php in windows?

Photo from Unsplash

Since the release of version 7, PHP has seen steady improvements with a new version released each year.

A PHP version usually gets active support for 2 years and security fixes for one year, which means a version is supported for three years since its initial release.

You can view the versions supported by PHP maintainer in php.net.

This tutorial shows how you can update the PHP version installed on your computer.

Update PHP using Homebrew [Mac]

For Mac computers, you can update the PHP version installed on your computer using Homebrew.

Run the brew upgrade command from the terminal as shown below:

Once the upgrade is completed, check your PHP version using php -v command:

You should see the latest PHP version shown in the terminal.

Update PHP for Linux Ubuntu

If you’re using an Ubuntu computer, you can update the installed PHP by running the following commands:

sudo apt-get update
sudo apt-get install php

Once the installation is finished, you can check the installed PHP version using php -v command:

$ php -v
PHP 8.1.2 [cli] [built: Apr  7 2022 17:46:26] [NTS]
Copyright [c] The PHP Group
Zend Engine v4.1.2, Copyright [c] Zend Technologies
    with Zend OPcache v8.1.2, Copyright [c], by Zend Technologies

If that doesn’t work, then you need to add the PPA repository created by Ondřej Surý to install the latest PHP version.

To install PPA easily, you need to get software-properties-common installed on your computer:

# 👇 install software-properties-common
sudo apt -y install software-properties-common

# 👇 use add-apt-repository command to install the PPA
sudo add-apt-repository ppa:ondrej/php

# 👇 refresh the package manager
sudo apt-get update

# 👇 install latest PHP version
sudo apt -y install php8.1

At the time of this writing, php8.1 is the latest PHP version. You should update the version to match the latest available PHP version when you follow this guide.

Once the installation is finished, check your PHP version again. You should have the latest PHP version printed on the terminal.

Update PHP for Windows

When you use a Windows computer, you can download a PHP distribution from windows.php.net and install it manually on your computer.

Download and extract the zip file from the website, then replace your existing PHP installation with the one you just downloaded.

Don’t change the folder name because Windows won’t be able to find the PHP folder if you do.

Run php -v from the command line to check your PHP version.

If you don’t want to update PHP manually, you can use the Chocolatey package manager to install and update PHP version for you.

Chocolatey is a package manager for Windows computers, it works like Homebrew for Mac computers.

Install Chocolatey on your computer, then install the PHP package with the following command:

# 👇 install php with Chocolatey
choco install php

# 👇 update php with Chocolatey
choco upgrade php

Once the update process is finished, you should have the latest PHP version available from Chocolatey.

Update PHP version in cPanel

To update the PHP version in cPanel, you need to log into the cPanel system first.

Inside the cPanel, you need to find the Select PHP version menu located in the Software tab:

Click on the menu, then change the Current PHP version option as shown below:

Once you change the PHP version, click the Set as current link that appears beside the version number.

cPanel will work to switch the PHP version and restart your website server.

Please keep in mind that not all web hosting provider provides you with a cPanel.

If you use BlueHost or SiteGround as your web host, you can visit the Update PHP for WordPress guide that I’ve written previously.

There are also several other hosting provider guides that you can find here.

Now you’ve learned how to update PHP version installed on your computer with this tutorial. Good work! 👍

I'm trying to get my Laravel project to work. But when I use composer update it says the following:

This package requires php >=5.6.4 but your PHP version [5.5.12] does not satisfy that requirement.

I'm using WAMP which runs php version 7.0.4 this is also confirmed in the browser if I echo the php version. But when I use php -v in the console it shows that I'm using PHP version 5.5.12 [cli].

I've searched a bit around on google and I found out that it uses my windows PHP version instead of my webserver's version. But I couldn't find out how to update my PHP version on Windows.

My PATH contents are as shown in the following image

worldofjr

3,8098 gold badges34 silver badges48 bronze badges

asked Sep 9, 2016 at 17:49

4

You can uninstall composer, and while re-installing it will ask you to point at your PHP directory which is going to be C:\wamp64\bin\php [usually] at that point you can choose which PHP version you would want to use. good luck.

Jquestions

1,5421 gold badge20 silver badges29 bronze badges

answered Oct 27, 2017 at 6:55

3

This means you have yet another installation of PHP in your system. Check your Programs in Control Panel and remove such installation.

However, you can modify your PATH environment variable as well. Procedure

Just remove the path that points to any PHP installation directory.

Else, otherwise, if you are unsure about changing the PATH variable [which can lead to serious problems if not set well], you can just delete the directory that the PATH variable points to.... [I mean the PHP directory]

The totally better solution is to add the path of your PHP7 bin directory at the beginning of the PATH variable. You should also make available composer in this PHP7 bin directory.

Such as, replace the C:\php in your path with C:\wamp\bin\php7 or whatever the location of the PHP7 path is..

answered Sep 9, 2016 at 17:56

Huzaib ShafiHuzaib Shafi

1,0839 silver badges23 bronze badges

3

To update PHP on Windows 10.

You must put the folder of the new PHP version in the same folder as the old. You rename the old folder or you delete it, prefer rename the old folder, now you write in a terminal console

php - v

PHP automatically check for a new version

answered Oct 18, 2020 at 14:27

1

if you had installed before xampp/wampp and composer globally you might had added php to you environment path to call it where ever you want, and now you want that composer use the new xampp with php the you recently installed, so go to system>advance tab> environment variable> maybe in PATH then search if you have something like C:\xampp\php and edit to your new php location.

I had multiple versions off xampp for testing and composer globaly instaled for php 7.2

hello_world

7781 gold badge10 silver badges26 bronze badges

answered Jul 20, 2018 at 14:28

How do I update my version of PHP?

How do I change the PHP version?.
Log in to your one.com control panel..
Scroll down to the Advanced settings tile and select PHP and database settings..
Scroll down to Update PHP version..
Select the PHP version you want to switch to and click Update..

What is the latest version of PHP for Windows?

Current Stable PHP 8.1.10 [Changelog] ¶.
Old Stable PHP 8.0.23 [Changelog] ¶.
Old Stable PHP 7.4.30 [Changelog] ¶.

Should I update my PHP version?

One of the most important reasons to update PHP is to ensure you are running on a version that is fully supported and patched regularly for security vulnerabilities. PHP 5.4 has not been patched since 2015. And PHP 5.5 has not been patched since 2016.

How do I upgrade to PHP 7?

User Contributed Notes 1 note.
Login to the server via SSH as root. ... .
Check your current version of PHP. ... .
To install PHP 7.3, we must first add the repository: ... .
Then run an update: ... .
After completing the update, we need to install PHP 7.3. ... .
Then install the required PHP packages according to your current installation:.

Chủ Đề