Easy PHP (Laravel, Symfony) Development with Docker using DDEV

DDEV is an open source tool that makes it simple to get local PHP development environments up and running in minutes. Extend and share per-project environment configurations.


Installing DDEV

Windows using Chocolatey:

choco install ddev

Mac/Linux using Brew

brew tap drud/ddev && brew install ddev

Mac/Linux install script

curl -L https://raw.githubusercontent.com/drud/ddev/master/scripts/install_ddev.sh | bash

Using DDEV in your project

Inside your PHP project’s root directory, run ddev config to setup the configuration of DDEV. Once complete, you can type ddev start to run the containers inside of Docker. Initial setup and pulling of containers will take a minute or two, but once the containers are downloaded, starting and stopping DDEV will be a cinch.

Once complete, DDEV will give you two URLs, http://project.ddev.site and to use for local development. If you wanted to share your project, you need to install ngrok and then you can run ddev share.

For more information on using DDEV’s CLI click here.

Extending DDEV

For a basic installation, that’s it, you’re all finished. However, if you need to extend DDEV, you have complete freedom. For instance, you can go to /.ddev/config.yaml and change or add configuration parameters. Here’s my config file as an example…

APIVersion: v1.13.1name: blogtype: phpdocroot: publicphp_version: "7.4"webserver_type: nginx-fpmrouter_http_port: "80"router_https_port: "443"xdebug_enabled: trueadditional_hostnames: []additional_fqdns: []nfs_mount_enabled: falseprovider: defaultuse_dns_when_possible: truetimezone: ""

You can also add your own custom commands. For instance, if you have a Laravel project you can create a file called artisan inside the /.ddev/commands/web directory. Within this file add the following

#!/bin/bashphp artisan $@

This will allow you to run any artisan command such as ddev artisan make:migration create_comments_table and it will generate a new migration file.

For testing, I added a file named phpunit with


This allows me to run ddev phpunit and it will run my testing suite. The same can be done for Symfony’s console command. Create a file called console inside the same web directory as before and add the following.

#!/bin/bashphp bin/console $@

And now you can run any Symfony console command using ddev console debug:router etc. If you would like to read more on this, then please take a look at their custom commands documentation.

Closing thoughts

I’ve covered the basics of using DDEV, but there is a lot more that it can do. You can switch from nginx to apache, change PHP versions and even add services such as Memcached, Solr, Beanstalk and more.

I’ll make another blog post in the future which goes into more details about these other services, but in the meantime you can sign up to my newsletter using the form below.

Leave a Reply