<img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=278116885016877&amp;ev=PageView&amp;noscript=1">

, , , ,

Jun 28, 2022 | 2 Minute Read

How To Set Up A Local WordPress Development Environment With Lando

Table of Contents

Introduction

Almost every developer has used WAMP, MAMP, and XAMPP. Developers are familiar with how the development of every project requires a different set of tools. It’s also not possible to install or uninstall different versions of tools for a project.

These issues get tiring very quickly. This is why developers must learn how to build a WordPress development environment with Lando. With this solution, developers can make direct changes to WordPress sites, get the website live when it’s ready, and handle all sorts of development challenges efficiently.

What Is Lando?

Lando is a command-line tool that simplifies creating a local development environment. It takes advantage of Docker to create reusable containers. This saves time as developers don’t need to install and configure each container. It makes setting up the local WordPress development environment fairly easy.

Before setting up the development environment, one must look into the requirements for setting up Lando on a device.

Refer to the official Lando documentation for details related to installation and system requirements for Lando.

Getting Started With Lando WordPress

The first step to starting with Lando is creating a project folder.

  • Open the terminal and make your project folder.
    mkdir wplandoprj
    cd wplandopr
  • Initialize the Lando site.
    lando init --recipe wordpress --webroot wordpress --name wplandoprj

Now, one must configure the Lando environment. To do so, open the .lando.yml file in the editor of choice.

In the past, developers had to copy libraries into plugins and themes to include them. Composers can simplify some of the management of these dependencies by allowing the use of a third-party library without reinventing it. This saves time.

What Is Composer?

Composer is a tool for dependency management in PHP. If composer is not installed, refer to the installation instructions for setting up composer. If already installed, skip this step.

The next step is to initialize composer in the project folder.

composer init

When prompted to enter the package name and other details, enter the relevant information on each prompt or skip by pressing the enter key. Finally, confirm yes to create a composer.json file.

John P. Bloch’s process will be followed for installing WordPress. To know more about this process, follow John P. Bloch on GitHub.

In the terminal window, install the following packages

composer require johnpbloch/wordpress-core-installer

composer require johnpbloch/wordpress-core

The next step is to use the platform.sh config-reader package. Later, the project will be deployed on platform.sh. This library provides a streamlined and easy-to-use way of interacting with the platform.sh environment. It offers utility methods to access routes and relationships more cleanly than manually reading the raw environment variables. Once again, in the terminal window, execute the following command.

composer require platformsh/config-reader

Next, create a wp-config.php file in the WordPress folder of the project. Create a file with wp-config.php name and copy the following code into the wp-config.php.

Copy this same wp-config.php file to the webroot folder. For the current example, the WordPress folder is the webroot folder.

Now, create a local wp-config-local.php file in the project's root folder. Add the following code in the wp-config-local.php file.

Installing WordPress Plugins And Themes With Composer

It is important to let the composer know where to install WordPress plugins and themes and install them from the WPackagist repository. After the minimum-stability line, add the following line.

Finally, install wp-cli using composer. The benefit of using wp-cli is that it is easier to maintain a WordPress site. One can do administrative tasks like updating plugins and themes, taking a database backup, publishing content, and performing database operations from the command line.

composer require wp-cli/wp-cli-bundle psy/psysh --ignore-platform-reqs

The composer.json file should look like this:

Now, in the terminal window, run:

composer install

lando start

It will start creating an environment for the project. Once completed, a URL will be presented for the project.

Key Takeaways

Learning how to install Lando WordPress locally is useful. It enables developers to make site changes, test themes, run updates, and test plugins in a risk-free environment.

It might feel overwhelming at first, but with practice using WordPress locally will become second nature. The benefits outweigh the learning process and will help developers take their WordPress skills to the next level.

About the Author
Viral Mehta, WordPress Developer
About the Author

Viral Mehta, WordPress Developer

Forever excited about all things tech, Viru is also deeply passionate about fine arts. He sketches, paints, listens to instrumental music, reads, and watches movies in his free time.


Leave us a comment

Back to Top