Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

oka_'s avatar
Level 1

How to change php version in laravel?

I have already done with my website in LARAVEL, but when I try to upload it to Cpanel, Cpanel doesn't support PHP v 8 or higher, but in my project, I'm using PHP 8.0.2 version, what am I supposed to do?

0 likes
11 replies
rodrigo.pedra's avatar

If you wrote your project in Laravel 9, you are out of luck.

Laravel 9 (the current one as of this post) only supports PHP >= 8

You can backport/adapt your project to a previous Laravel version, or change hosting provider.

If you choose to backport your project, you can create a Laravel project using an older version, with this command:

composer create-project laravel/laravel:^8.0 example-app

Than you can start copying your models/routes/controllers/etc. and test for any newer feature you might be using that is not supported on the older version.

When, and if, you find an unsupported version, you will need to workaround it yourself.

reference:

https://laravel.com/docs/8.x#installation-via-composer

1 like
oka_'s avatar
Level 1

@rodrigo.pedra if I choose to back up and create a new project with the older version of LARAVEL, am I have to re-install the older version of PHP too?

and in your command example, you type the 8.0 version of laravel, is that gonna support the PHP 7.4 version?

rodrigo.pedra's avatar

@oka_

Laravel 8 supports PHP 7.4, 8.0 and 8.1

You can keep your local PHP 8 if you already have it. You just need to be aware of not using any feature that is not available to PHP 7.4.

IDE's such as PHP Storm, will warn you against unsupported features despite of your local PHP version.

If you want to be 100% sure your code will work on PHP 7.4 and don't have an IDE that would warn you, I would consider also using PHP 7.4 on your local machine

1 like
oka_'s avatar
Level 1

@rodrigo.pedra Alright, the way you explain the solution is really great, it's giving me a chance to complete my project in my internship. I think I understand now, Thanks a lot.

I'll try your solution for this problem ASAP, god bless you @rodrigo.pedra

1 like
oka_'s avatar
Level 1

@rodrigo.pedra sorry sir, I did the backup laravel to a lower version, and after some discussion with my office, I have to downgrade my PHP version to 7.4 in my laravel project, is that possible? and how can I do that?

rodrigo.pedra's avatar
Level 56

@oka_

I have to downgrade my PHP version to 7.4 in my laravel project, is that possible?

Sure, you just need to ensure you have PHP 7.4 available locally and in your production server.

Also check your project's composer.json file for the "php" entry under the "require" key. If you downgraded to Laravel 8, as suggested, it should be something like this:

   "require": {
        "php": "^7.3|^8.0",

reference: https://github.com/laravel/laravel/blob/78ad150a947f6677d9cb4e3eb9a257d312fe14c3/composer.json#L8

Which means the project will run on PHP versions 7.3, 7.4, 8.0 and 8.1 (as of this writing).

I'm using XAMPP btw

Unfortunately I am not familiar with XAMPP.

From their download page, there is a version 7.4 download available:

https://www.apachefriends.org/download.html

Maybe it will override your current installation. But I can't tell for sure.

1 like
priyalaks's avatar

You can talk to your hosting service provider for a php upgrade .. Some of them agree to upgrade when they try to provide better service.

oka_'s avatar
Level 1

@priyalaks but, I read on Cpanel documentation, it said "cPanel & WHM does not support DSO on PHP 8.0 and higher.", is it possible to change the PHP version in cPanel to 8 versions or higher

Please or to participate in this conversation.