Set up a blazing fast Magento 2 development environment in less than 10 minutes

Running multiple Magento 2 development environments is hard. You have to check out the code, install Magento and end up with a very slow environment. Have you tried a VM? Too slow! Have your tried the Docker environment? Better, but still painfully slow! So you end up with a local setup and configuring vHosts and all this stuff for every project you are working on. What is the easiest way to set up a blazing fast development environment?


Valet is a minimalistic development environment which runs locally on your Mac. It supports multiple project types like generic PHP, Laravel, Magento 2, Craft CMS, Symfony or just WordPress.

  1. Install Laravel Valet via the Official Documentation
  2. Go to your root project where you store your projects and add it to Valet by typing valet park into your terminal. Valet is now watching all projects in this directory. If you only want to link a single project, go to the root of the project and type valet link project-name

Now you can access your PHP projects with or like magic.

Optional: I’ve created a Valet extension for creating databases with a simple command. I’m using it every time I setup a new project.

command('db [name]', function ($name) {
  if(!$name) {
    warning('Please specify a database name');
  if($error = CommandLine::run('mysql -uroot -e "create database '.$name.'"')) {
  } else {
    info('The database '.$name.' has been created');
})->descriptions('Create a new database');

Put this file into your ~/.valet/Extensions directory and restart Valet with valet restart. You can create a new local database with valet db DB-NAMEnow.

Magento Setup

Install Magento 2 via composer and add the --use-rewrites=1 flag during the setup! If you don’t do it, Magento adds the server.php of Valet in your URL and all links are broken.

bin/magento setup:install --admin-firstname=FIRSTNAME --admin-lastname=LASTNAME --admin-user=admin --admin-password='PASSWORD' --base-url='' --db-name='DB-NAME' --backend-frontname=admin --use-rewrites=1

Bonus: Share your local development environment with a client

Share your local environment with a simple valet share command. Valet creates a local tunnel via ngrok and gives you http and https URLs for a direct access. Whether you are behind a corporate firewall or not.

Make sure to update your Base URLs in Magento and, as always, clear your cache with bin/magento cache:clean.


No virtualization anymore! For most shops, this setup is quite reliable for development. Sure, it might not work for an enterprise version with different caching layers and a lot of services, but for most PHP and Magento projects, it works fine — and it’s fast.


Beyond Code GmbH
An der Lingenmühle 10
41061 Mönchengladbach

Commercial Register
Amtsgericht Krefeld, HRB 16540


Managing Partners
Marcel Pociot, Sebastian Schlein

Beyond Code GmbH © 2018