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
Initialize lando in current directory:
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
xdebug and MailHog and phpunit
Optional step, but it’s best before going further to add phpunit, MailHog and
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
This builds the new site and then shows URLs for the site.
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
Also Great For Pantheon
This article is about setting up local sites for general plugin development. We also use Lando for local development of the Caldera Forms site. CalderaForms.com is hosted on Pantheon. We git commit the Lando config file in the repo for the site. That way we have a shared environment and can pull database and file changes using Lando’s CLI, thanks to their Pantheon integration.
Also published on Medium.