Search code examples
phplaravelvagranthomestead

Using Laravel Homestead for PHP5.6 and PHP7 projects


Here at the office we are using Homestead as our local development environment. All projects we had so far were made in PHP5.6. Now we have a new project and we are going to use PHP7. I can't run PHP7 in my current PHP5.6 homestead machine. How can I achieve to run PHP5.6 and PHP7 projects? They do not have to run at the same time, so I if it's possible to change the Homestead.yaml to use a newer version, that would be fine.

What I have tried already was to run vagrant box add laravel/homestead --box-version 1.0.1. This added the 1.0.1 box but when I added version: 1.0.1 to my Homestead.yaml and started vagrant the PHP version was still on 5.6.


Solution

  • In case people find this post - the answer has changed.

    If you run Homestead v6 or above - you automatically get multiple PHP versions installed by default.

    In your Homestead.yaml file you can set the version:

    sites:
        - map: homestead.app
          to: /home/vagrant/Code/Laravel/public
          php: "5.6"
    

    In addition, you may use any of the supported PHP versions via the CLI:

    php5.6 artisan list
    php7.0 artisan list
    php7.1 artisan list
    

    Check the Laravel docs for more info: https://laravel.com/docs/5.4/homestead#multiple-php-versions