Running multiple Homestead boxes next to each other (PHP 7 and PHP 5.6)

Now that PHP 7 is being adopted by more and more web applications in production environments, dealing with legacy code in local development becomes increasingly more difficult because of the different PHP versions out there and deprecated functionality. The reason I’m writing this article is that for a big project, we’re planning a migration from PHP 5.6.15 to PHP 7.x, but had some issues with the legacy mcrypt extension (which we adapted from Laravel 4.2) in local development.

The mcrypt extension has been abandonware for nearly a decade now, and was also fairly complex to use. It has therefore been deprecated in favour of OpenSSL, where it will be removed from the core and into PECL in PHP 7.2.

I’ve been using Laravel homestead for years now because it’s such an easy tool for Laravel development. But it’s not that easy to setup a 2nd Laravel box, with an older PHP version. In this blog I’ll show you how to do it. Hopefully it will help other developers.

I’m assuming you already have a Homestead box up & running. Make a backup of your Homestead.yaml configs and save it someplace safe, because we’re going to start all over just to make sure. All your code is hosted locally anyway so you’re not going to lose anything, unless you made custom changes to the VM which is not a good idea anyway.

Remove all boxes:

vagrant global-status --prune
id       name        provider   state   directory
2d2e481  homestead56 virtualbox running /Users/Chris/Homestead56
1042da7  homestead7  virtualbox running /Users/Chris/Homestead
vagrant destroy [id]

Now let’s setup our new VM’s:

vagrant box add laravel/homestead
vagrant box add laravel/homestead --box-version 0.3.3

Pull in Homestead:

cd ~
git clone Homestead
git clone Homestead56

Here’s the tricky part, edit ~/Homestead56/, change the homesteadRoot variable. Otherwise it will try to overwrite the file in the other Homestead folder.

#!/usr/bin/env bash
mkdir -p "$homesteadRoot"
cp -i src/stubs/Homestead.yaml "$homesteadRoot/Homestead.yaml"
cp -i src/stubs/ "$homesteadRoot/"
cp -i src/stubs/aliases "$homesteadRoot/aliases"
echo "Homestead initialized!"

Next run:

bash Homestead/
bash Homestead56/

This will publish the config files to ~/.homestead/ and ~/.homestead56/.
In order for both environments to function properly we’ll have to make a couple of changes to the Homestead.yaml files.


ip: ""
name: "homestead7"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/
    - ~/.ssh/id_rsa
    - map: ~/Sites
      to: /home/vagrant/Sites
    - map:
      to: /home/vagrant/Sites/randomapp/public
    - homestead


ip: ""
name: "homestead56"
version: 0.3.3
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/
    - ~/.ssh/id_rsa
    - map: ~/Sites
      to: /home/vagrant/Sites
    - map:
      to: /home/vagrant/Sites/randomapp/public
    - homestead

As you can see we’re setting up different IP’s for the VM’s (duh), specifying an easy-to-remember name, and most important of all, we’re setting the VM versions. These define what PHP version will be installed.

Bonus, symlink your vagrant commands to your VM environments.

vim ~/.bash_profile

# Homestead
function homestead() {
    ( cd ~/Homestead && vagrant $* )
function homestead7() {
    ( cd ~/Homestead && vagrant $* )
function homestead56() {
    ( cd ~/Homestead56 && vagrant $* )

Now you can do something like:

homestead56 up
homestead56 ssh
homestead7 up
homestead7 ssh

If you want more information on the available PHP / Homestead versions, try these links:

Behind the scenes @ Coolblue HQ

What is Coolblue?

Last week I was invited to go visit Coolblue behind the scenes in Rotterdam, NL. Coolblue has always been one of my favorite online dutch/belgian webshops because of their great customer service, their clear but simple websites, and most important, their great range of products at very affordable prices.

They roughly have about 50k unique products in 150-200 different webshops (they launch 2 new webshops per week on average), which they all have in stock at all time in one of their huge warehouses. Their biggest warehouse is more than 40.000 square meters which is about 10-20 FIFA football fields! How big is that! Ordering before 23.59 means it’s delivered at your doorstep for free the next day, or the same day when paying additional shipping costs. Also on sunday!

Why would they organise behind the scenes events?

The main idea behind this ‘Behind the scenes’ is that they are looking for talent programmers. They’re looking for roughly 100 new developers. They have about 40 right now so it seems they have big plans. Are they going international? Who knows! But their CEO didn’t really deny it. Their global employee basis is about 750 people.

Since I’m a freelancer I won’t be able to work for them so why did I go to this event? Well.. because their main dev talk was about scalability. I find this a very interesting and challenging topic so getting insights from one of the biggest webshops in the Benelux was a great opportunity for me to learn.

So what did I learn at Coolblue?

  1. use microservices / hypermedia api’s to flatten out your infrastructure. This allows you to easily isolate bugs and/or maintain those API’s without having to retest stable services on every deploy.
  2. every microservice uses an isolated datastore. CouchDB for customer data, PostgreSQL for order+payment information, ElasticSearch for the product catalog.
  3. RabbitMQ as a central state change notification mechanism. This is the glue between your microservices.
  4. use git pull requests to review & validate your team members changes
  5. CentOS RPM packages to distribute everything
  6. Puppet labs or Chef to install & maintain your (virtual) servers
  7. Statsd + Graphite for advanced reporting
  8. Nagios for alerting
  9. Create a “Chaos Monkey”. It’s single purpose is to once in a while kill your live environment. Your devs should then come with solutions to auto-fix these downtimes. This is how Netflix stayed online during the massive AWS outage a while ago:

Have a look at the slides from their software architect.

Why should you attend one of these meetings?

  1. If you want a developer job @ Coolblue obviously.
  2. If you want to learn more about scalability.
  3. If you want to network with hundreds of other devs.

Inform yourself on this page:

Here’s a nice dutch article about the same event:

Raspberry Pi PLC/Domotica testcase

Here’s a quick tutorial on how to build a hardware on/off switch which sends this signals to a RESTful web API using Raspberry PI with Raspbian. This is in fact a small PLC testcase (proof of concept). The possibilities are in fact endless!
I’m planning to use this to monitor certain events around my house. E.g. is a door open/closed? Is a device on/off?

Download & install Raspberry

Download the latest version of Raspbian onto your Raspberry PI SD card:

Updates & depencies

Do some updates + install extra depencies:

apt-get update
apt-get install python, py-pycurl

Setup the hardware

In order to know the GPIO’s pins you’ll have to find the input/output pins. Here’s a map:

Connect your Raspberry’s GPIO (the big black serial thing) to some switch or toggle. Here’s how I did it (testcase):


We actually need 3 pins. One for I/O, one for power, and one for grounding (safety first!). Make sure you solder the right cable to the right GPIO pin (see map above).

Now you might experience the naming of these pins are confusing. That’s because there’s 3 type’s of naming conventions used here..

Pin Numbers RPi.GPIO Raspberry Pi Name BCM2835
P1_01 1 3V3
P1_02 2 5V0
P1_03 3 SDA0 GPIO0
P1_04 4 DNC
P1_05 5 SCL0 GPIO1
P1_06 6 GND
P1_07 7 GPIO7 GPIO4
P1_08 8 TXD GPIO14
P1_09 9 DNC
P1_10 10 RXD GPIO15
P1_11 11 GPIO0 GPIO17
P1_12 12 GPIO1 GPIO18
P1_13 13 GPIO2 GPIO21
P1_14 14 DNC
P1_15 15 GPIO3 GPIO22
P1_16 16 GPIO4 GPIO23
P1_17 17 DNC
P1_18 18 GPIO5 GPIO24
P1_19 19 SPI_MOSI GPIO10
P1_20 20 DNC
P1_22 22 GPIO6 GPIO25
P1_23 23 SPI_SCLK GPIO11
P1_24 24 SPI_CE0_N GPIO8
P1_25 25 DNC
P1_26 26 SPI_CE1_N GPIO7

Anyway, let’s move on and try & catch the GPIO’s input using python.

Read GPIO signals using Python (daemon script)

import RPi.GPIO as GPIO
import time
import os
buttonPin = 07
while True:
  if (GPIO.input(buttonPin)):
    os.system("sudo python /home/pi/")
    #print "button called"

import time
import RPi.GPIO as GPIO
import datetime
import pycurl, json
buttonPin = 07
# reset state
last_state = -1
while True:
  input = GPIO.input(buttonPin)
  now =
  # check if value changed
  if (input != last_state) :
    	print "Button state is changed:",input, " @ ",now
	api_url = ""
	data = "location_id=1&status=%s" % input
	c = pycurl.Curl()
	c.setopt(pycurl.URL, api_url)
	c.setopt(pycurl.POST, 1)
	c.setopt(pycurl.POSTFIELDS, data)
  # update previous input
  last_state = input
  # slight pause to debounce

You can run this script doing this:

sudo python /home/pi/

Or add it to /etc/rc.local (so it runs after each reboot)

python /home/pi/
exit 0


Here’s a quick (and unsafe) ‘API’ script for receiving the Raspberry signals:

header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Content-type: application/json');
$dbh = new PDO('mysql:host=localhost; dbname=database', 'username', 'password');
$response = array(
    'status'    => 'nok'
    $status = $_POST['status'];
    $location_id = $_POST['location_id'];
    // create log
    $sql = "INSERT INTO status_log (location_id, status, created_at, updated_at) VALUES (:location_id, :status, NOW(), NOW())";
    $q = $dbh->prepare($sql);
    $q->execute(array(':location_id' => $location_id,
                      ':status'      => $status));
    // update location  
    $sql = "UPDATE location SET status=:status, updated_at=NOW() WHERE id=:location_id";
    $q = $dbh->prepare($sql);
    $q->execute(array(':location_id' => $location_id,
                      ':status'      => $status));
    // output
    $response = array(
        'status'    => 'ok'
echo json_encode($response);

Now I’m very curious what sort of applications you guys are building with this Raspberry Pi “plc implementation”. Feel free to post them in the comments section.

Usefull links


Politiecontrole? duldt geen concurrentie

Chris Schalenborgh, de oprichter van het gratis platform PushControl, kreeg vorige week een brief van de advocaten van Politiecontrole? in de bus.

Maasmechelen, 13 juli 2012 – Politiecontrole? is een bekende Facebookpagina, met ongeveer 83.000 fans. Het bedrijf erachter bracht ook recent een mobiele applicatie uit, waar ze een vaste maandelijkse bijdrage vraagt voor het gebruik van de app. En net daar wringt het schoentje, want PushControl – de webapplicatie van Chris Schalenborgh – is volledig gratis.

“Ik kreeg enkele weken geleden een brief van de advocaten van Politiecontrole?, waarbij ze vragen om mijn applicatie te verwijderen. Ze vragen een maandelijkse bijdrage voor hun applicatie, ik reken niets aan voor dezelfde meldingen. Waarschijnlijk zijn ze daar niet zo blij mee”, zegt Chris Schalenborgh, “Al bij al hadden ze het ook eerst op een andere manier kunnen vragen. Echt rechtvaardig is het nu niet.”

“Klopt”, zegt Matthias Dobbelaere, ICT-­-jurist bij mylex en aangesteld vertegenwoordiger van Chris. “Eerst en vooral mist het schrijven van de tegenpartij elke juridische grond. PushControl neemt slechts de data (statusupdates) over van de gebruikers, en nooit van de Politiecontrole? zelf. Deze statusupdates van de gebruikers zijn publiek en openbaar, en Politiecontrole? verkrijgt hierover geen enkel auteursrecht of databankrecht. Politiecontrole? doet bovendien niks meer dan eenvoudig de statusupdates van haar gebruikers kopiëren. Ze spreken ook over een ‘deloyale’ handelspraktijk, maar cliënt vraagt zelfs geen enkele vergoeding voor de applicatie. Hij gelooft ten stelligste in ‘open data’. Sowieso betaalt de gebruiker van PolitieControle? nu maandelijks, voor zijn eigen inbreng. ”

“Het lijkt er dan ook op dat Politiecontrole? vooral zijn betalend business model via de juridische weg wil afdwingen. Of dat zo’n goed idee, valt af te wachten.”, vervolgt Dobbelaere, “Uiteindelijk is het de gebruiker die zal moeten inzien dat het hier gaat om een valabel, waardevol en gratis alternatief”.

Over PushControl

PushControl verzamelt open data, en wil absoluut gratis blijven. Zij verzamelt statusupdates van gebruikers van de Facebookpagina, en ‘pusht’ deze informatie verder door in haar informatiestroom. Meer informatie kan je terugvinden op

PushControl is een gratis service voor het ontvangen van meldingen van politiecontroles. Hoe werkt PushControl? Aan de hand van zelf in te stellen keywords kan je bepalen welke meldingen je krijgt. Bovendien kan je ook instellen wanneer je geen meldingen wilt ontvangen (bv: ‘s nachts), en langs welk kanaal je de meldingen wenst te ontvangen (email, sms, twitter, ..). Volg de uitgebreide handleiding en krijg binnen 5 minuten controles gratis op uw gsm.



New project: Souschef – Social Food Platform

After a year of development we finally launched, a social food platform for foodies located in Belgium/Holland.
Souschef has a vast database of recipes and restaurants, all linked together by our usergroup, giving it a final social touch.

Check it out and leave your feedback :).