Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 258
Bart Bergmans Avatar asked Jan 23 '17 10:01

Bart Bergmans


2 Answers

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

like image 138
Laurence Avatar answered Sep 17 '22 19:09

Laurence


The latest Laravel-Version with Homestead including PHP 5.6 is Laravel 5.6. See https://laravel.com/docs/5.6/homestead for details and installation instructions.
Use the following commands during installation to get this Homestead-Vagrant-Box:

vagrant box add laravel/homestead --box-version 6.4.0
git clone https://github.com/laravel/homestead.git .
git checkout v7.20.0

This Homestead-Version supports PHP 5.6 to 7.3.
(More details in german: https://blog.dmr-solutions.com/blog/homestead-vagrant-box-mit-php-56)

like image 23
Ralf Lütke Avatar answered Sep 17 '22 19:09

Ralf Lütke