Note: This article is written with macOS in mind. Nearly all of this is available on Linux, but certain steps may differ slightly.
As web developers, we have lots of projects, and each project can use different technologies. Some projects may need basic PHP, HTML, and CSS while others may need a combination of PHP, node / npm, HTML, and SASS. Because of this, we often install global versions of PHP, NPM/Yarn, Composer, Git, etc.
What do we do if we are working on legacy code? Ideally, we don't have to, but we don't live in an ideal world unfortunately. That old application that runs on PHP5 and uses features deprecated in PHP7? Yep, someone has to maintain that. So we need a flexible solution. One that can run multiple versions of PHP and other languages/products without messing with each other.
A complex containerized (Is that a word? It is now.) solution where all of these things are possible. It runs as 'containers' or small virtual machines that can have silo'd software. But many of us never adopted Docker as it can be too complex for the amount of time we have. Who has time to learn in-depth server-like configurations when we are supposed to be building websites and web apps?
Then came Lando, an abstraction layer built to provide powerful features with simple configuration. It sits on top of Docker (even installs it for you) and makes it much easier to work with. They are better authors than I, so below I've included a snippet of their work to better explain it.
Lando is for developers who want to:
- Quickly specify and painlessly spin up the services and tooling needed to develop their projects.
- Ship these local development dependencies in a per-project, lives-in-git config file
- Automate complex build steps, testing setups, deployments or other repeated-more-than-once workflows
- Avoid the built-in-masochism of directly using docker or docker-compose
It's a free, open source, cross-platform, local development environment and DevOps tool built on Docker container technology and developed by Tandem. Designed to work with most major languages, frameworks and services, Lando provides an easy way for developers of all skill levels to specify simple or complex requirements for their projects, and then quickly get to work on them.
Think of it as your local development dependency management and automation tool.
It's a great tool, and I highly recommend it., but what is a good way to install it? You can follow other methods of installation on docs.lando.dev, but we are going to use homebrew. Why? Because its awesome!
According to the authors of Homebrew, it "installs the stuff you need that Apple (or your Linux system) didn’t." Put in the language of Wikipedia, "Homebrew is a free and open-source software package management system that simplifies the installation of software on Apple's macOS operating system and Linux."
But wait, there's more! What if I were to tell you there's a better way to use your terminal, would you be interested? Well, too bad if not because here it comes!
ZSH is a great alternative to bash. But theres a certain utility that makes it totally worth it: oh-my-zsh.
As a framework for a ZSH shell, oh-my-zsh opens up the possibility for 'plugins' which are collections of aliases and other utilities (such as themes) to make the terminal a breeze (even a joy) to use. This allows for a very significant increase in efficiency.
We will look at each individual part below, but for an easier way to automate all of the below steps, checkout my dotfiles. The README on that repo can explain all the steps. The two most necessary files for this step are setup.sh which utilizes the Brewfile to install the various brew components.
For those who wish to install manually, see each step below.
Installation of Homebrew is pretty simple, just run the below command on your terminal and voilà! You now have Homebrew installed! P.S. This script will explain what it will do and pause before doing it. You can read more about other options and details in the Homebrew Documentation.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Since we now have homebrew, that makes the rest of this a breeze.
First, we install the zsh shell itself.
brew install zsh
Now, all we have to do is to set it as the default shell.
chsh -s $(which zsh)
Sweet! now that ZSH is installed and set as default, lets install an awesome framework.
sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
Now that we have our terminal setup, let's install Lando.
brew install lando
Now that we have that installed, we can install my ZSH plugin for lando.
cd ~/.oh-my-zsh/custom/plugins
git clone git@github.com:JoshuaBedford/lando-zsh.git lando
git clone https://github.com/JoshuaBedford/lando-zsh.git lando
SITES_DIRECTORY
variable with the directory your sites/projects are found in.CONFIG_FILE
variable if your config file is a different name.