#20 HTML-over-WebSockets, WordPress development with Docker, and more
Welcome to the 20th issue of The VOLT newsletter! Here's a few things from the last couple weeks:
Is the future of web HTML-over-WebSockets?
Earlier this month I came across a pretty interesting article about a potential “Future of Web Software”. In it, the author proposes an alternative to the current way of developing things like SPAs and REST APIs. Instead of your frontend making occasional calls to a backend service, getting back data in the form of JSON, and then making updates to the DOM, it would work a little different.
Your frontend application would connect to your API through a WebSocket server. When a call or request is made to the backend, instead of getting back JSON, you’d receive plain HTML elements that would replace what’s currently in the DOM. Essentially, skipping a step that your frontend code and browser engine would have to do.
There’s already a few frameworks like Basecamp’s Hotwire and Laravel Livewire, although these don’t use WebSockets (yet). The adaptation of pushing finished HTML through to the frontend instead of raw data seems to be trending, and could definitely make its way into more mainstream applications in the near future.
Creating a solid WordPress dev environment with Docker
Last week I released a new video on my YouTube channel, showing how to create a local WordPress development environment from scratch using Docker and Docker Compose. It’s aimed toward beginners to Docker and containerization, but you could find some useful information in it if you have some experience as well!
If you don’t want to sit through the whole tutorial, check out the description for helpful links to specific parts of the video that I’ve highlighted.
Orbit - A flat-file database driver for Laravel Eloquent
“Orbit is a flat-file driver for Laravel Eloquent. It allows you to replace your generic database with real files that you can manipulate using the methods you're familiar with.”
Installing the package and getting it set up in your new or existing Laravel application is fairly straightforward. You can use migrations, primary keys, soft deletes, and validation rules just like with a typical SQL database. Additionally, it comes with 4 different file drivers you can use (Markdown, JSON, YAML, and Markdown JSON).
Generating Laravel Components with YAML
Speaking of YAML, I recently learned of a popular Laravel package that has been around for a couple of years: Blueprint.
Today I learned
This hint came from a few different developers on Twitter, and is a feature that exists in multiple languages (including PHP and Bash). It’s called heredoc syntax, and it’s a way of specifying and assigning formatted strings to variables in your code.
Here’s a quick example of what that looks like:
Our $content variable now contains three lines, since heredoc lets newlines persist, and our variables have also been injected easily into the text block. All we have to do is specify the same keyword at the beginning and end of our content!
That’s it for now! If you have any questions about the above, or have something you’d like me to check out, please feel free to let me know on Twitter.