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

knubbe's avatar
Level 36

How to use PHP 8 in laravel homestead?

I just update laravel homestead to latest version v10.17.0. Also I update virtual box and vagrant. Related to laravel homestead documentation php 8 should be supported but I wasn't able to setup.

PHP 7.4 is still default version but that is not a problem because I want to use version 8 only for one project and I set php: '8.0' in Homestead.yaml for specific site but there is no impact at all. I also see there is a function for switching to version 8 in vagrant but I get command not found.

Does anyone have an idea?

0 likes
18 replies
bugsysha's avatar

Have you read the docs?

If you change the sites property after provisioning the Homestead virtual machine, you should execute the vagrant reload --provision command in your terminal to update the Nginx configuration on the virtual machine.

knubbe's avatar
Level 36

Of course. But on vagrant I still have 7.4

bugsysha's avatar

So vagrant reload --provision does not help?

Diab's avatar

Been in the same boat a couple of days ago, according to the laravel docs you can set PHP version used by the CLI by issuing the following commands:

php56
php70
php71
php72
php73
php74

so in your case php80 And the site PHP version through the Homestead.yaml file:

sites:
    - map: homestead.test
      to: /home/vagrant/project1/public
      php: "8.0"

then just run vagrant reload --provision

confirm the CLI PHP version with PHP -v and the app version with phpinfo() from within the app and view it in the browser.

2 likes
knubbe's avatar
Level 36

As I said in question when I use php80 I get command not found

svpernova09's avatar

In your Homestead folder there is an aliases file. If you've edited this file, back it up. Then delete aliases and run bash init.sh again to regenerate the aliases file. Now vagrant destroy then vagrant up and you should have the php80 alias.

knubbe's avatar
Level 36

I never edited aliases file before. Can I edited this file manually with this:

function php80() {
    sudo update-alternatives --set php /usr/bin/php8.0
    sudo update-alternatives --set php-config /usr/bin/php-config8.0
    sudo update-alternatives --set phpize /usr/bin/phpize8.0
}
brandymedia's avatar

@Diab Thanks for the answer. I did not realise you could specify PHP version like that.

I added php: "8.0" and now my app works 😉

1 like
JigSawIII's avatar

I have the same issue, i need change to php 8 and nothing work! Any help?

travis.elkins's avatar

Just jumping in to say that I'm having the same issue as @knubbe and @jigsawiii . It seems like it shouldn't be this difficult....but here I am struggling nonetheless. :-)

travis.elkins's avatar

Actually, I think I did get it to work. I tried so many things, none of which seemed to help. Then, I realized that I had php: "8.0" under folders instead of under sites. Once I fixed this I ran vagrant reload --provision and all was well.

I'm still not sure that something else wasn't necessary, but I don't really want to take the time right now to wipe everything, start from scratch, and see if that's all that was required. Maybe for another day or another project.

brandlions's avatar

I had the same problem ("realized that I had php: "8.0" under folders instead of under sites"), which fixed it. Should confirm that's all that was required.

raghavan's avatar

This will change php CLI version, but not php FPM version. So, if you run php -v you'll see it's showing version 5.6. However, when you write phpinfo() under your app and run from browser you'll get version 7.3. https://typhoon-tv.org/

Please or to participate in this conversation.