Tangible Bytes

A Web Developer’s Blog

Laravel Frankenphp Octane Sail

My Laravel project is in part a headless CMS - this means it has and API that gets called by a frontend system - with around 10 API requests per page view.

We can cache some of that - but sometimes caches are empty and the site still has to be responsive.

The meant I needed to optimise my Laravel site and after a few experiments I found that using [Laravel Octane]](https://laravel.com/docs/12.x/octane) with FrankenPHP gave me the performance boost I needed without needing any significant code change.

Read more ...

Kubernetes Multi Container Pod

So far on my Kubernetes journey I’ve only ever had one container per pod.

But I needed to run php-fpm fronted by nginx - with static assets served direct by nginx.

A lot of online examples skip this complexity by serving both php and static assets via Apache.

While it seemed complex at first - like a lot of Kubernetes it’s fairly straightforward once you have made the leap.

Read more ...

Security Hardening Php

Most of what you read about securing PHP is how to write secure code - and that is really important.

In addition it helps to setup PHP on the server for best security.

There is plenty we can do to harden the setup without hurting the functionality we need.

The more layers we have in our security setup the better.

Read more ...

PHP Docker for Dev

I’m staring a new PHP project and I wanted a clean docker image to work from.

I inherited one on my last project and wanted to improve image size, security and production alignment.

Read more ...

Laravel Route Binding Null/Empty Object

Laravel’s routing and binding is nice

But when I got it wrong I didn’t get the kind of error I expected

Laravel automatically resolves Eloquent models defined in routes or controller actions whose type-hinted variable names match a route segment name.

use App\Models\User;
 
Route::get('/users/{user}', function (User $user) {
    return $user->email;
});
Read more ...