This article has been updated in 2020, please go to DDEV-Local From Scratch on macOS.
In this video tutorial, we’ll show you how to use DDEV-Local to set up a PHP development environment from scratch on macOS.
Using a local development environment means you’re working on your projects without risking injury to your live projects.
Follow instructions to install DDEV-Local in the docs or watch this video for an overview.
How to install your Docker-based dev environment with DDEV-Local
First: Install Docker for Mac
The minimum requirements to run DDEV-Local are Docker and Docker Compose, which comes bundled with Docker for Mac and Windows. DDEV-Local pretty much works anywhere Docker will run.
Next: Install DDEV
Option 1: With Homebrew
You can install DDEV-Local with Homebrew, and if you’re using Mac it’s a handy way to install.
brew tap drud/ddev && brew install ddev
Option 2: Install the DDEV binary with a script
curl https://raw.githubusercontent.com/drud/ddev/master/install_ddev.sh | bash
You run the same script later to upgrade.
Set up your first project with DDEV.
In a typical web development workflow, most of the time you’re working in a repository that includes the web root for your PHP application or website. So the first thing is to cd to change directory so you’re inside that project folder or docroot.
Then you’ll answer 3 questions about the project. DDEV will make a best-guess, and usually, you can just keep the defaults.
- Project name – DDEV will base the name on the current directory name.
- Docroot – Again, DDEV will make a guess from the docroot you’re currently in.
- Project type – DDEV will auto-detect if you’re using a CMS, or use PHP if you’re building a custom application.
The first time you configure a project, it will download the containers you need. In the future, it will come up even faster.
When you’re done, DDEV outputs a URL with the link to quickly view your site in your browser.
Working on a new project? Or an existing one?
If this is a first-time project based on a PHP CMS like TYPO3 CMS or Drupal, you would have to go through the installation steps to set up the site.
Otherwise, you might be loading an existing project, and you’ll want to import an existing database.
These are some good commands to know but check ddev -h to see the complete list.
ddev listto see what projects you have running.
ddev describeto get information about the project.
ddev sshto SSH into the container.
ddev removeto throw away the container but not the database. Pick up your project quickly next time.
Need some help?
We hope the video helps you set up your new Mac web development environment set up. If you get stuck, we’re happy to help.
- Add questions tagged “ddev” to Stack Overflow.
- Join the #ddev channel in Drupal Slack and TYPO3 Slack for community support.
- Tweet to @drud
Photo by Maxime Le Conte des Floris on Unsplash