Create A WordPress Site With Lando

Josh Pollock
Sep 7, 2018 · 3 min read
Image for post
Image for post

For local WordPress and Laravel development, I tend to use a Docker-based solution, most of the time. Depending on the project, I either use Lando or docker-compose. This post is about Lando.

Lando, is no DesktopServer. DesktopServer gives you a simple GUI for creating WordPress sites. Lando has no user interface, you do everything from the command line. That’s good or bad, depending on what you need.

Here is how I create new sites for local development using Lando.

Create The WordPress

lando init --recipe=wordpress

Add a WordPress:

wp core download
wp config create --dbname=wordpress --dbuser=wordpress --dbpass=wordpress --dbhost=database --skip-check

That downloaded WordPress core and setup wp config to match Lando’s default variables:

wp config create --dbname=wordpress --dbuser=wordpress --dbpass=wordpress --dbhost=database --skip-check

Add xdebug and MailHog and phpunit

I love xdebug, I can’t imagine PHP development without it.

In order to run tests “The WordPress Way” you need phpunit installed globally. I disagree with this approach, but Lando makes it pretty simple to do, so fuck it. Here is a .lando.yml file that adds all of these things:

name: formcalderas
recipe: wordpress
config:
env: dev
xdebug: true
proxy:
mailhog:
- mail.formcalderas.lndo.site
services:
appserver:
composer:
phpunit/phpunit: '*'
mailhog:
type: mailhog
hogfrom:
- appserver
portforward: true

Build Containers And Start the site

lando start

This builds the new site and then shows URLs for the site.

Image for post
Image for post

At that point you have a WordPress at the URL listed for “APPSERVER URLS”. Click the https link and then finish installing WordPress through the UI. Alternatively use wp cli.

Chrome will not trust the SSL certificate. I normally just click the “Advanced” option and then tell Chrome to trust it. There is a better way to handle this documented here.

Path Mappings For xdebug In phpStorm

Image for post
Image for post
In phpStrom preferences go to Language & Frameworks > PHP > Servers and select the current server. Map the root directory to /app

Also Great For Pantheon

Learn more about Lando + WordPress here.


Originally published at Josh Pollock.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store