New Year, new stack

This year I want to own the full stack again.

New Year, new stack

I started this year with the goal to re-align my professional tech stack. For years now, I've been almost exclusively writing vanilla Javascript for clients and while it was an interesting and fun journey, I feel like I want to widen my palette again and "own" the full stack again. Javascript, especially written in the nobuild way without utilising the Node/NPM ecosystem, has revitalised my belief that frameworkless development is not only possible but often quite superior to framework-driven solutions, especially for small-scale applications made by a single dev.

But restricting myself to this part of the stack, the frontend, meant that I was always reliant on people providing backend services and APIs whose functionality and feature-set was out of my reach. I was getting the itch to try some techniques and mindset I've practised with Javascript in other parts of the stack too. Coming from a strong PHP background and seeing the recent developments in this space, I've become genuinely interested in exploring it again.

PHP

As of writing this article, the current major release version of PHP is version 8.4.

There have been some interesting developments in PHP like optional type declarations, an exciting new match expression I'll probably overuse and year over year performance increases.

For a long time, I believed that PHP was the de-facto language of the web. Not because it is so ubiquitous, but because it feels "web-first". Other languages like Ruby or even Javascript have their original use-cases still in their bones somehow, it just shines through. Building and delivering web pages from the backend with these languages seems like an afterthought.

PHP, on the other hand, always seems eager to deliver everything over HTTP and provides all the means to do so right at hand.

On top of this, PHP does not need proprietary tooling, has no strong ties to any company and no BDFL, which today has become a peace of mind I expect from new tools I invest my time in.

Static websites

Practically un-hackable, maintenance-free and edge deployable with crazy performance, these are the hallmarks of static websites. With these benefits, I think static websites speak for themselves and should be the first approach to be considered for any project. Only the second step should include dynamic functionality, maybe in the form of sprinkling dynamic content onto a static website via a backend API and leaving the full dynamic applications only to authentication-driven user-centric web applications.

Given the fact that PHP is also an extraordinary backend for building static web pages makes this a great match.

Web Components

During my vanilla Javascript journey, I've written quite a few web components to know the good, the bad and the ugly truths about them. And while many criticisms about them might be valid, Web Components or Custom Elements are just a great way to encapsulate (and probably re-use) frontend functionality.

The best and mind-changing use-case for me was to use Web Components progressively enhanced. In this scenario, you don't render an empty tag like this,

<my-custom-tag></my-custom-tag>

and then fill it with content on load, you basically write your HTML elements like you always would and wrap the ones you want to add dynamic functionality too, like this.

<my-button>
  <button>Press me</button>
</my-button>

Because Custom Elements just render as block-level elements by default, in most cases this won't affect rendering at all. The button will be fully visible before Javascript is loaded (maybe add pointer-event:none to prevent early clicking) and even if Javascript isn't available (yeah I know how likely that is) or something else goes wrong, there won't be any loading flashes.

Works great with static content generation too. (We might have a theme here)

Laravel, TYPO3

Sometimes, of course, your clients expect to author content in elaborate ways, and my clients are no different. For these cases, I've decided to go with the framework Laravel and in other special cases with the CMS TYPO3.

Both are PHP-based open-source projects with a long history and stable releases, and best of all: they are not WordPress.

Both also offer the ability to make their content available via API and could potentially be integrated into a static website generation workflow as well.

This will be my new tech stack of choice for web projects going forward. Centred around open technologies, static and HTML first, optimised for performance and maintainability.

Discussion