I’ve been working a lot with Laravel lately and a really nice side effect of doing so has been using the very lean Laravel Valet for local development. It is super lean, super fast, and the more I use it, the less I want to be messing about with virtual machines.
Ok, I don’t actually have a beef with VMs. Or at least, I don’t have any more of a beef with VMs than what I have with most things (for those who know me.)
I’ve been developing on virtual machines for a while now. I started on VVV and more recently moved to Chassis.io and, honestly, it’s been a valuable experience but does make some aspects of the work more difficult. e.g; switching between projects to handle support related issues means I have
Oh and don’t get me started on resource usage.
VMs are still decent kit in my mind and will continue to play a role in my development work but for most projects I work on, I would seriously benefit from being able to quickly jump between them.
Having worked with Laravel Valet on a few different projects now, I gotta say – I’m super impressed. New sites are practically instant, there is no DNS management required and it only uses, like, 7 MB of RAM…holy smokes! Turns out there is even a WordPress driver built into the system, so I guess there is at least one other person in the Laravel space also building on WordPress. Bully for me!
I don’t really see any point going through the basics of how to use it because the Laravel Valet documentation is (as always in the Laravel space) really nice and easy to follow.
What I do want to share, however, is my boilerplate.
I put together a boilerplate purely because I
like torturing myself with distractions really like reducing the amount of thinking I have to do, particularly when firing up a new project.
So, I got to work on my own little boilerplate which brings a few good things to my table:
I’ve introduced the notion of a single PHP file that returns an array with a bunch of configurable items. This array is used to populate the local WordPress config, create and authenticate a user, install and manage plugins, configure WP Migrate DB Pro, configure SMTP, define log files, … and other things.
I just really dig having the WordPress core to be in a sub-directory, adjacent to my wp-content directory, when I work locally – it just feels so much cleaner and makes it much easier to change WordPress versions via Git or WP CLI. So, this boilerplate does that, too.
One of my biggest time sucks is FTP and media libraries. It drives me nuts – particularly when I bork my schedule and forget to do it in advance. For this reason, I always aim to proxy images from the live site unless they exist on my local disk as this means I rarely need to download media. I’ve previously been doing this with NGINX directives but, as far as I can tell (and may well be wrong), per-site NGINX config on Valet just isn’t easy.
Fortunately, Valet uses a PHP class-based driver system which can also support a per-project driver just by declaring a class
Nothing too grand here, but I hate log files just appearing an any willy-nilly directory. They belong in a log directory damn it, so that is where I’ve put them.
Not sure what else to say on this… *crickets*
wp valetbpfor easy synchronisation with remote sites
I really, really dig WP CLI and I often use bash scripts to handle sync-related stuff. I thought it might be nice to set up a command instead, so I did. Details of the sub-commands can be found in the readme but it basically introduces a command to sync the database using WP Migrate DB Pro (buy it using this affiliate link, if you dare), change active states on plugins I only use locally, then log me back in. It’s kinda nice when things are automated.
Now, I kinda really sorta maybe built this with myself in mind. So, for that reason, it’s probably pretty bias towards my own needs and wants and may not totally suit yours. Keep that in mind and feel more than free to fork it – who knows what I might copy from your fork…
If you liked this article, I'd be incredibly grateful if you tweeted about it.
Also, I don't send emails often but when I do, I try to fill them full of useful goodies. If you like code snippets & dev tips, join my mailing list. There's no catch but I'll probably want to tell you about any new plugins & tools I build.