Rethinking Server-Side Rendering in Modern PHP Applications

dymissy 8 views 49 slides May 15, 2025
Slide 1
Slide 1 of 49
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45
Slide 46
46
Slide 47
47
Slide 48
48
Slide 49
49

About This Presentation

Server-Side Rendering (SSR) is making a comeback, offering a balanced approach between performance, simplicity, and modern user experience. In this talk, we’ll explore how SSR is evolving in the PHP ecosystem, focusing on practical tools like Laravel Livewire and Symfony UX. We’ll dive into real...


Slide Content

Rethinking Server-Side
Rendering in Modern PHP
Applications
SIMONE D'AMICO - PHPDAY 2025

Have you ever worked with SSR applications?
WHAT THIS TALK IS ALL ABOUT

Simone D'Amico
TECH TEAM LEADER @
Full-time dad of two, Lego enthusiast, and
speaker. Author of Lead Through Mistakes,
a newsletter focused on leadership in the IT
world.

simonedamico.com
leadthroughmistakes.com
linkedin.com/in/simonedamico

WHAT I'VE BUILT USING SSR
A Real Use Case

A Real Use Case
Revamping the listening platform to
improve listening and interaction
experience
MEDIA INDUSTRY
Hard to maintain, hard to evolve.
Legacy technologies and libraries
15+ Y/O PHP MONOLITH
Millions of search engine–indexed
pages
CONTENT ORIENTED
Team primarily skilled in PHP, little to
no experience in JavaScript
PHP-CENTRIC TEAM
Solid APIs already available in the
CMS
ROBUST EXISTING APIs
To test the product present it at a
major industry event
SHORT TIME TO MARKET

The Final Solution
BFF built to serve the
frontend consuming
existing APIs
Powered by CloudFront,
Lambda, and Bref delivering
everything at the edge, with
no traditional hosting
SSR allowed also to deliver
a fast, seamless user
experience similar
SSR to preserve SEO
performance and prevent
loss in search engine
visibility
BACKEND FOR
FRONTEND
SERVER-SIDE
RENDERING
SPA-LIKE
EXPERIENCE
SERVERLESS
ARCHITECTURE

AN INTRODUCTION
Server-Side Rendering

Server-Side Rendering
Source: https://prismic.io/blog/what-is-ssr

SSR vs CSR

JS is not a bad guy but this
doesn't necessarily mean it
has to be used for
everything.
SSR allows to use JS for
what it is made for: user
interactions
It can be integrated into
existing applications
incrementally, without
rewriting everything from
scratch
No multiple stacks and
codebases to maintain,
evolve and keep updated
Ensure a single source of
truth for State management
to avoid inconsistent data,
increased complexity,
overhead, unclear
separation of concerns
REDUCE JS USAGE
01
STATE CENTRALIZED
02
SINGLE STACK
03
EASY INTEGRATION
04
Why SSR in PHP?

A set of tools and conventions that let you
progressively enhance server-rendered
templates using JavaScript, without adopting a
full SPA framework. It integrates closely with
Twig, Stimulus (for interactivity), and Turbo (for
navigation and updates)
A full-stack framework for Laravel that lets you
build interactive components using Blade and
PHP. It can be enhanced with Alpine.js for small
frontend behaviors, without requiring a full
JavaScript framework
What does the PHP ecosystem offer for SSR?

Is there a pattern we can follow?
Yep. It is very common in the Javascript world
and it is called: Component-Based Architecture
More info: https://ux.symfony.com/cookbook/component-architecture

Composition
Independence
Props
State
Composition
A page is no longer just a page but rather a collection of small,
reusable components

Composition
Independence
Props
State
Independence
The component lives in its own context. It should not be aware of the
rest of the page

Composition
Independence
Props
State
Props
The component must remain independent, but we can customize its
props. Props flow in one direction, from parent to child

Composition
Independence
Props
State
State
A state is pretty much like a prop, but the main difference is that a
state can change during the life of the component

LIVEWIRE AND SYMFONY UX IN A NUTSHELL
Quickstart

A working example
github.com/dymissy/ssr-in-php

Installation

Create a template layout
It requires an HTML layout for components to
render inside
Components are rendered inside traditional
Twig blocks

Create a route
Livewire components can be registered as
routes
Components are rendered inside traditional
Symfony routes

Create a component
Components are PHP classes that inject properties to a template

Create a component
Components are PHP classes that inject properties to a template

Create an anonymous component
Components that don't require any custom logic beyond the properties injected

Cool, but… everything is static so far.
What about interactions?

1. State Change

Live components
Components that allows their own state to change during the component lifecycle

How does it work under the hood?

Live components
Components that allows their own state to change during the component lifecycle

How does it work under the hood?

Interaction with parent components
We can rely on events

Interaction with parent components
We can rely on events

2. SPA-like Navigation

SPA-like Navigation
Livewire will prevent the standard
handling of the link click and replace it
with its own, faster version

SPA-like Navigation
Thanks to Turbo library, Symfony watches
for link clicks and form submissions,
performs them in the background, and
updates the page without doing a full reload.

Forms
Livewire provides loads of helpful utilities for building them

Forms
Turbo Drive automatically converts form submissions to AJAX calls.
To get it to work, you do need to adjust your code to return a 422 status code on a validation error

The result
github.com/dymissy/ssr-in-php

Kind of hard to test with all this interaction,
isn’t it?

Testing
Source: https://livewire.laravel.com/docs/testing

Testing
Source: https://symfony.com/bundles/ux-live-component/current/index.html#test-helper

Still Not Enough? Craving More?

Want to take them to the next level?
Pre-built Live Components let you add
dynamic, reactive UI features without writing
JavaScript — just use PHP and Twig
Volt is a functional API for Livewire that
supports single-file components, allowing a
component's PHP logic and Blade templates to
coexist in the same file

Integrating with JS libraries

KEY TAKEAWAYS BEFORE YOU GO
Wrapping Up





We faced several challenges along the road:
performances
overweight states
shared sessions to allow coexistence with
legacy website during the migration
Octane memory leaks
IT WASN'T ALL SMOOTH
02
The context mattered.
Native Tailwind support and a Laravel-skilled
team made all the difference
WE OPTED FOR LARAVEL
01
Key Takeaways

SSR works best when when you need fast initial
load, great SEO, or simple user flows (eg.
content platforms).'
SPA fits better when complex client-side
interactivity is the priority — like real-time
collaboration or design tools.'
The key is not ideology, but context
SSR ISN'T A ONE-SIZE-FITS-ALL SOLUTION
04
SSR in PHP is not just for new projects.
It works well even in existing apps. You can
start small, one component at a time, without
rewriting everything
NOT JUST FOR GREENFIELD PROJECTS
03
Key Takeaways

Thanks ??????
linkedin.com/in/simonedamico
✉️
leadthroughmistakes.com
simone.damico86[at]gmail.com
Rate the talk!