Local Development

WordPress local environment with lando

Programmer and supervisor in server room doing brainstorming

Introduction

In the world of web development, having a robust local development environment is paramount to success. It provides a controlled sandbox where developers can experiment, test, and refine their code without impacting a live website. This isolated environment not only safeguards against unintended consequences but also fosters rapid iteration and efficient debugging. A well-setup local environment should provide:

  • Replication of the production server: Mimicking software versions, database configurations, and server settings to ensure accurate testing.
  • Easy installation and configuration: Streamlining the setup process for developers to quickly get started on projects.
  • Tooling for debugging and testing: Integrated tools to identify and fix code errors efficiently.
  • Isolated environment: Preventing conflicts with other projects and ensuring code changes don't affect live websites.

By closely mirroring the production server, a local environment allows developers to identify and resolve issues early on, ensuring a smoother deployment process and a higher quality end product for users.

Tools in the market

It’s been a while since XAMPP or setting up a server on your computer was the only option to start developing locally with WordPress. These worked but it wasn’t perfect when trying to sync up changes, especially if we talking about multiple websites on multiple servers.

Nowadays is really important to containerize all of the code and server features so we have exactly the same running specs on our local machine and on the server the website is going to run.

For these, some tools are available on the market.

  • Local - An all-in-one development tool with a nice User Interface that allows you to start and develop locally with ease.
  • Docker: A container-based tool to create isolated development environments.
  • Vagrant: Creates and manages virtual machines, providing a consistent development environment across different operating systems. It allows you to create a machine exactly as the production server and thus provide consistency across all the environments.
  • DevKinsta: A cloud-based solution offering pre-configured environments for WordPress development. It provides a close match to Kinsta's hosting environment, but requires a subscription.

In my long career as a developer, tech lead and freelancer I’ve worked with a lot of tools and it’s important to evolve as the market changes in order to get to achieve the best results while keeping up-to-date with the latest productivity standards.

Because of this I tend to focus on two technologies:

Vagrant

Vagrant and virtual machines are pretty resource intensive and thus have been losing market to docker and containers however I still prefer it when I need to provision staging and production servers.

Especially Trellis. It comes with out-of-box playbooks to provision local, staging and production servers which is perfect to assure that everything is running with the same specs and the same way.

Docker

Docker is pretty lightweight and comprehensive however it can be hard to set up everything just right due to the amount of possibilities it provides.

Enters Lando. It allows to quickly and easily create a setup file and literally start the environment. It’s best to use in agencies where you need to have the same local environment set up for multiple developers really quickly.

Lando start

Lando, however, can be pretty raw out-of-box so a bit of tweaking and set up is needed in order to have all the tools needed for the vast needs a WordPress project requires.

Entres Lando Start. A tool to speed up local environment set up and assure that all the tools needed are properly set up with a few command lines:

  • Bedrock: I’ve mentioned this multiple times but bedrock is my go-to tool for a brand new WordPress installation.
  • Sage: My preferred starter theme as well. It comes with a lot of tools and processes in order start a theme from scratch the right way.
  • Mailhog - an email testing tool for developers.
  • PhpMyAdmin - A free software tool intended to manage databased on the web.
  • Node.js - Allows to run npm, yarn and thus build the sage theme.

Starting your project

  • Cloning the Repository:
git clone https://github.com/raramente/lando-start
  • Configure the Environment: Edit the .lando.yml and .env.lando files to suit your project requirements.
  • Start the Environment: Run the following command:
lando start
  • Install WordPress and Sage: Use the install-bedrock command to set up your WordPress environment with Bedrock and Sage:
lando install-bedrock
  • Access Your Site: Once the setup is complete, you can access your WordPress site and additional tools like PhpMyAdmin and Mailhog using the links provided by Lando.

Development tools

Even if you have the proper tools installed on your local machine, you shouldn’t be performing task such as compiling you assets and installing composer packages from that local machine. This because, most of the times, the version of PHP you have installed is not the same as the one as the project and the same works for the node and npm versions you need to compile your assets.

Lando WordPress Starter Project takes advantage of the lando tooling capabilities to provide a command line interface for these features out of box:

  • Composer:
lando composer require "wpackagist-plugin/contact-form-7":"6.0.2"

Using lando composer you can easily run composer commands from inside the container for the app server.

  • WP CLI
lando wp user list

WP CLI should be a tool that you use on your day-to-day activities. It allows for a lot of features and speeds up WordPress development. With this project you can run these commands quite easily without having to ssh into a virtual machine or lando.

  • Compiling theme’s assets
lando theme-build

And easy and quick way to compile your theme with a single command.

Why Use Lando Start?

Lando Start saves time and effort by automating the setup of a robust local WordPress development environment. It eliminates the need for manual configuration and ensures compatibility with modern development practices.

Conclusion

If you’re looking to enhance your WordPress development workflow, Lando Start is a fantastic tool to consider. By leveraging the power of Lando, Bedrock, and Sage, it provides a seamless experience for developers. Explore the repository today and elevate your local development setup!

0 Comments

Share a Comment

Leave a Reply

Your email address will not be published. Required fields are marked *