Beyond WP
October 13th, 2020

Beyond WP #1 - Local dev setups, and no pressure!

Beyond WP #1 - Local dev setups, and no pressure!

I told you there wouldn't be a schedule. Life happened. Thanks for waiting!

Hooray! For two reasons:

  1. You signed up for Beyond WP - thank you and I hope you enjoy it!

  2. We made it as far as issue 1!

Before we begin:

A note on the format

The Beyond WP visual theme is mountainous. You noticed the mountains in the logo, I hope? Did you spot that the mountains were “W”-shaped? Was that too subtle? 🤔

And so I’ve decided to carry on this metaphor in the content. Learning new tech can feel like hard work as your figure your way up-hill. But when you get to the top, the view is wonderful and you get a new perspective.

So the format of the newsletter will be sections called:

  • The Team - introducing people from other tech communities
  • Kit shop - tools (both paid and free) that may be useful to you
  • Base Camp - pause and learn something new in preparation for...
  • Ascent - I’m going to TRY to set some small tasks or coding challenges for you - not sure if this will work out - feedback welcome!
  • Debrief - my thoughts and reflections on software and business

I won't have every section in every newsletter. But this is the flavour of it.

Please note, for now, that I’m focussing on the Laravel framework and community because that’s the not-WordPress space that I know well. Perhaps, in future, there will be stuff from other communities that I find interesting.

And also note that I work on a Mac, so the tools I present here will often be Mac focussed, though I will try to research Windows and Linux options too.

Kit shop - tools for the job

Local dev setups

Let’s start at the very foot of the mountain. If we're gonna climb it we'll need some tools that will help us along the way.

We all need to run our code somewhere. It's good practice to have a local setup for development. Maybe, as a WordPress dev, you’re used to MAMP or WAMP, or maybe Local or VVV?

These are all great for WordPress. And they may also be great for developing with other languages or frameworks. But, equally, it may help to have other options. So let's look at some.

PHP: The... err... simplest way?

If you're happy to open up a command line or terminal, the simplest way to run PHP locally is to use the web server built in to PHP. For example, you can go to a project directory and type:

php -S localhost:8000

For WordPress, you can use the WordPress command-line interface to do the same from the root of a WordPress project:

wp serve

And if you want to try development with Laravel, that framework has a command line tool called “artisan” that can do the same:

php artisan serve

And some people love the simplicity of this approach. But doing this every time isn’t what every developer wants. And it only gives you the web server, nothing else (there's more on databases in a moment!).

Surveying the landscape!

So here's some other tools that do local development differently.

  • Laravel Valet - this makes use of a locally-installed PHP, MySQL (or equivalent) and an nginx web server and is really simple to use. It's for Mac's but a Windows port is available.
  • Laragon - a Windows-based tool that packages a bunch of web development tools
  • Lando - a cross-platform local development toolset based on Docker
  • Laravel Homestead - a Vagrant wrapper for PHP development that uses a virtual machine and includes a good set of developer tools like Mailhog, XDebug and wp-cli (yes - you can use it for WordPress development too). This is very similar to VVV but less specifically WordPress-focussed.
As I now work for WP Engine, I'm using Local as my daily driver at work and it's really good for WordPress work too. But you can't really get "Beyond WP" with it and it's not a general-purpose local web server for other frameworks and projects.

I'm also seeing an increasing trend towards separate containerised services using Docker, which some people are writing some nice wrapper tools for. But this seems like a more advanced next step!

I, personally, have benefitted hugely from Valet on my Mac for not just Laravel development, but for WordPress and Statamic development and general HTML/CSS/JS tinkering too. Valet is fast, free, and gets out of the way and lets me do my coding.

The great thing about Valet is that the steps to starting a project are minimal: new directories created in your projects folder are instantly served on their own local domain, like this:

Short GIF of creating a new local site in Valet

So if, like me, you have lots of projects on the go, and like to quickly spin up new local sites, it's a superb tool.

The main downside for some is that you'll need to do some command-line stuff to get it set up, including using Homebrew and Composer, and if it breaks it can be a little tricky to fix. So it's not for everyone.

Since writing, there are new tools that help here, especially if you're on a Mac. PHP Monitor is a superb little menu-bar app that effectively gives you a GUI for Valet. And Laravel Herd is a similar tool that replaces Valet. These tools make it REALLY EASY to run PHP locally.

I should note that some of the tools I've mentioned here include databases, but Valet in particular only provides the web server parts. So you'll also need to install a database. You can install MySQL with Homebrew on a Mac, or there are simple GUI's like DBNgin that make installing databases easier. And you may also want a database management tool like SequelAce, Querious or TablePlus. I'll cover database management tools in more depth in a future issue!

I did not cover database management tools in more depth in a later issue. 😬

I won't go into exactly how to install and use Valet here, but if you're intrigued, and you use a Mac, look it up and see if it's a tool that can help you.

NEWS: Even while writing this, helpful new tools have been announced. David Hemphill has announced a GUI that he is building for doing Valet-like things (installing web servers and configuring sites) called "Valet Lite". It's in Beta, but look out for it in the future for a simpler way to run a web server like this (he has a newsletter!).

It appears David abandoned this project and it never got out of Beta.

Of course, there's good reasons to use the other solutions. If you want your dev environment to mirror your live environment, you probably need a virtual-server-based tool. And there are good reasons to use Docker-based tools as well.

Finally, there is also an enhanced fork of Valet called Valet+, and a Windows fork too (though it looks a bit out of date).

So... you have some other options for local development. Don't be afraid to experiment when you have time. You might find something new works better! I found MAMP's frequent, bulky updates and clunky GUI was hindering me, and Valet was a breath of fresh air.

Ascent - take some steps

The little practical task I'd like to set for you to do is to consider your current local development environment and maybe try something new. Does your setup only support WordPress development? Or is it flexible enough to support you as you look Beyond WP? Can you quickly spin up new projects for trying things out? And tear them down once they're done?

It can be a big job to download and try out a new local dev environment. So maybe you just save this email and refer back to it later. (I'll find some way to make an archive of information sometime too!)

Or maybe you want to dive straight in and try out something new to see if it works better? Do this when you have a good chunk of time, and don't hold me responsible for anything going wrong!

Or maybe that's too much right now and you'll take a smaller step in that direction: learn some command-line/terminal commands (I have a few free videos I started making) to help you get going with the command line. Or get Homebrew and/or Composer installed and ready to go for the future.

Let me know how you get on!

Debrief - thoughts and reflections

No pressure!

During the (very long) process of getting issue 1 out, I saw a Tweet about how we don't have to change. I paraphrase from memory:

If the thing you're doing now works: if it makes your productive; if it earns you money; if it gets the job done; then don't waste time looking at new shiny things and don't get distracted by micro-optimisations. Keep doing what you're doing.

And that person was right. And I just want to stress, in this first issue: while I see the role of the newsletter as encouraging you to try new things, there's no guilt or shame in sticking with what you have.

Hopefully you're signed up to Beyond WP because, like me, you find there's something fun about trying stuff out. There's something exciting about having a go at something new.

It doesn’t have to be a success. Failure is a part of both the creative and learning processes. Finding out what doesn’t work is as important as finding out what does work! We'll never progress if we're not experimenting and tinkering.

I'm not saying do these things in your day job right now. You need to keep your boss or clients happy. Keep doing the important stuff you're doing! Keep paying the bills!

But maybe you can find a spare half hour to look outside of the tools of your day job at something different? It might just be fun. Or it might profit you in future.

With all the tools and ideas I present in Beyond WP, if you're happy with what you've got, and have no reason to change: don't change!

My aim is to show you the things I've found, inspire you to look into new tools, and to encourage you to try things out to see if they work better for you.

Thanks for reading - I'll try not to leave it so long next time!