Rethinking Server-Side Rendering in Modern PHP Applications
dymissy
8 views
49 slides
May 15, 2025
Slide 1 of 49
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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...
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-world examples to show how you can build dynamic, reactive interfaces while leveraging PHP's strengths. Discover the benefits, trade-offs, and ideal use cases of this approach to craft applications that are fast, maintainable, and delightful to use—all without a full client-side framework. Whether you're a Laravel or Symfony enthusiast, or simply curious about modern SSR techniques, this talk will provide valuable insights for your next project.
Size: 14.55 MB
Language: en
Added: May 15, 2025
Slides: 49 pages
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.
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
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?
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!