Sign in

SymfonyCasts

@symfonycasts.com
732 followers 5 following 321 posts

Injecting Unicorns and Rainbows back into learning PHP // The official way to learn Symfony: SymfonyCasts.com

PostsRepliesMedia
SymfonyCasts @symfonycasts.com · 14h
Rewind ⏪ Cosmic Coding with Symfony #13 We get to try out one of my *favorite* parts! Asset Mapper is *the* tool for building a modern CSS & JS frontend without the fuss of a build system. It's time to make our site shine! symfonycasts.com/screencast/s...
symfonycasts.com
CSS & JavaScript with Asset Mapper
How Symfony 7 serves frontend assets with Asset Mapper, so CSS/JavaScript/images in assets/ can be referenced publicly with automatic cache-busting versioned URLs instead of being manually copied…
000
SymfonyCasts @symfonycasts.com · 29/09/2026
Rewind ⏪ Cosmic Coding with Symfony #12 We're making all sorts of pages in our new Symfony app. So for part 12, let's start linking them together! The secret is that every route already has an internal name and we can use it to generate URLs. symfonycasts.com/screencast/s...
symfonycasts.com
Generating URLs
Builds a dedicated StarshipController::show() page for displaying one ship, fetches the ship by route {id} via StarshipRepository, handles missing ships with a 404, and links to the page using…
010
SymfonyCasts @symfonycasts.com · 28/09/2026
Rewind ⏪ Cosmic Coding with Symfony #11 We can fine-tune the routes in our Symfony app in tons of cool ways: route {wildcards}, requirements, HTTP methods, etc! We'll use this to create another API endpoint and continue building our app with clean architecture. symfonycasts.com/screencast/s...
symfonycasts.com
Fancier Routes: Requirements, Wildcards, and More
Builds a more realistic API endpoint for fetching a single starship by ID using route wildcards, route requirements, HTTP method restrictions, route prefixes, repository lookup, and a 404 when the…
000
SymfonyCasts @symfonycasts.com · 25/09/2026
🔐 Symfony Security: Going Further #4 Wrong password, unknown email, disabled account... your login form answers all three with "Invalid credentials." That's deliberate. Let's decide how much we actually want to give away. symfonycasts.com/screencast/s...
011
SymfonyCasts @symfonycasts.com · 24/09/2026
Symfony Cache Contracts have a sneaky little trick 👀 Use `beta: INF` to force-refresh a cached value without deleting the old one first - so other requests can keep using it while the fresh value is computed. See how it works 👇 symfonycasts.com/blog/symfony...
symfonycasts.com
Force Refresh a Symfony Cache Item with beta: INF
Symfony's Cache Contracts have a mysterious third argument: "$beta". Here's where its name comes from, how it prevents cache stampedes, and how "beta: INF" lets you force a cache item to refresh…
011
SymfonyCasts @symfonycasts.com · 23/09/2026
🔐 Symfony Security: Going Further #3 Disabling an account blocks the next login... but a user already browsing doesn't even notice. Let's show them the door mid-click. 👋 symfonycasts.com/screencast/s...
011
SymfonyCasts @symfonycasts.com · 22/09/2026
🔐 Symfony Security: Going Further #2 Deleting a user is forever. Sometimes you just want to switch them off. Let's teach our login to check more than the password. symfonycasts.com/screencast/s...
011
SymfonyCasts @symfonycasts.com · 18/09/2026
Rewind ⏪ Cosmic Coding with Symfony #10 Symfony lives & dies by service - which are tools! It's packed full of them. But we can - & will - constantly create our *own* services! Let's do that to centralize our code & learn more about how autowiring *really* works. symfonycasts.com/screencast/s...
symfonycasts.com
Creating your own Service
Moves Starship data-fetching logic out of controllers into a reusable StarshipRepository service, then uses constructor autowiring, Twig object/property access, and |length to reuse that data on…
000
SymfonyCasts @symfonycasts.com · 17/09/2026
🚀 New on the blog: our ideal GitHub Actions setup for Symfony apps! Tests, linting, PHPStan, code style, database/schema checks, Symfony-aware diagnostics, asset compilation, plus a scheduled Composer security audit. A solid CI baseline you can actually build from: symfonycasts.com/blog/ideal-g...
symfonycasts.com
Ideal GitHub Actions for Symfony Apps
A practical, modern GitHub Actions setup for Symfony apps, covering tests, linting, static analysis, database checks, Symfony-aware diagnostics, and scheduled dependency security audits.
063
SymfonyCasts @symfonycasts.com · 16/09/2026
🚨 New Course 🚨 🔐 Symfony Security: Going Further #1 A 403 status code tells us we don't have access... but it also tells us the thing exists. Let's borrow the trick GitHub uses on private repositories 🖖 symfonycasts.com/screencast/s...
021
SymfonyCasts @symfonycasts.com · 14/09/2026
Rewind ⏪ Cosmic Coding with Symfony #9 Big chapter about... services! These are the backbone of everything in Symfony. We'll talk about the container, autowiring and where services come from. symfonycasts.com/screencast/s...
symfonycasts.com
Services: The Backbone of Everything
Symfony services are the objects that perform work in an app, and this chapter shows how the service container, bundles, and autowiring let controllers access built-in services like logging without…
000
SymfonyCasts @symfonycasts.com · 11/09/2026
Rewind ⏪ Cosmic Coding with Symfony #8 How easy is it to create a JSON endpoint in Symfony? Let's find out! Then, we'll create a "model" class to organize our data and find out how Symfony's serializer system can even turn objects into JSON. symfonycasts.com/screencast/s...
symfonycasts.com
Creating JSON API Endpoints
Builds a basic JSON API endpoint in Symfony 7, first by returning an array as JSON from a controller and then by switching to Starship objects so the chapter can introduce Symfony’s Serializer…
000
SymfonyCasts @symfonycasts.com · 10/09/2026
Symfony has a great login feature: Visit a protected page → log in → automatically return to the page you wanted. Unless Turbo has other plans... 😅 Here's what happened - and the fix. youtu.be/2oBFtu1cN2c
youtu.be
Turbo Broke My Symfony Login?!
One of Symfony's nicest login features: if you try to visit a page that requires authentication, you're automatically redirected to the login page. After you log in successfully, Symfony sends you right back to the page you originally requested. Unless... Turbo gets in the way. In this case, Turbo intercepts the login form submission and prevents the expected redirect to the protected page. The fix? Disable Turbo for the login form. Watch the full SymfonyCasts lesson: 👉 https://symfonycasts.com/screencast/symfony8-security/roles
000
SymfonyCasts @symfonycasts.com · 09/09/2026
Rewind ⏪ Cosmic Coding with Symfony #7 Symfony has some of THE best debugging tools of all the internet. With one command, let's pop the web debug toolbar and profiler into existence in our app! symfonycasts.com/screencast/s...
symfonycasts.com
Debugging with the Amazing Profiler
Installs Symfony’s debugging stack with the debug pack, then uses the Web Debug Toolbar, the Profiler, and bin/console debug commands to inspect routes, Twig, logs, and request performance.
000
SymfonyCasts @symfonycasts.com · 08/09/2026
End-to-end tests with JS but no web server?! 🎭 Playwright-PHP + Symfony hands the request straight to your Symfony kernel - so you get container access, PHP exception catching, DAMA rollbacks and ParaTest. From a real browser. 🤯 symfonycasts.com/blog/playwri...
symfonycasts.com
Playwright-PHP Changes the Game for Symfony Testing
Real browser. Real JavaScript
000
SymfonyCasts @symfonycasts.com · 07/09/2026
Rewind ⏪ Cosmic Coding with Symfony #6 Twig's template inheritance works exactly like OO inheritance (It was once implemented behind the scenes as OO inheritance!), we break our base template into as many parts as we want, then override those from the child. symfonycasts.com/screencast/s...
symfonycasts.com
Twig Template Inheritance
Uses Twig template inheritance so a page template can plug its content into a shared base.html
000
SymfonyCasts @symfonycasts.com · 04/09/2026
Rewind ⏪ Cosmic Coding with Symfony #5 I absolutely ❤️ Twig.We get to know the 3 Twig syntaxes, filters & more. Oh, and packs! Unrelated to Twig, packs are a way to install multiple packages at once to get everything you need for a robust setup. symfonycasts.com/screencast/s...
symfonycasts.com
Twig & Templates
Uses Twig in Symfony 7 to move HTML out of controllers, render templates with data, and understand Twig’s core syntax so controllers still return Response objects.
000
SymfonyCasts @symfonycasts.com · 03/09/2026
🔐 Symfony Security Basics #19 Let's finish by building a complete user registration flow! We'll generate the registration form, add validation, save our new user, log them in automatically, and finish with a discussion about user enumeration. symfonycasts.com/screencast/s...
021
SymfonyCasts @symfonycasts.com · 02/09/2026
Rewind ⏪ Cosmic Coding with Symfony #4 Fun fact: Symfony projects start as a *single* file: composer.json! So then where do the other files come from? Say hello to Symfony's unique recipes systems. We'll install PHP CS Fixer, skip configuration & use it immediately. symfonycasts.com/screencast/s...
symfonycasts.com
Magical Flex Recipes
Symfony Flex is a Composer plugin that makes symfony new start from a tiny skeleton and then expands the project by applying package recipes; this chapter shows how aliases and recipes automatically…
000
SymfonyCasts @symfonycasts.com · 01/09/2026
🔐 Symfony Security Basics #18 Symfony dispatches events throughout the security process. Let's explore some of the most useful ones, then put one to work tracking each user's last login! symfonycasts.com/screencast/s...
011
SymfonyCasts @symfonycasts.com · 31/08/2026
Rewind ⏪ Cosmic Coding with Symfony #3 6 minutes: that's all we need to explain the first half of Symfony: route -> controller -> response. The song of the web! symfonycasts.com/screencast/s...
symfonycasts.com
Routes, Controllers & Responses
Builds Symfony’s first real page by wiring a route to a controller method and returning an HttpFoundation\Response, establishing the core “route + controller = page” pattern.
000
SymfonyCasts @symfonycasts.com · 28/08/2026
End-to-end tests with JS but no web server?! 🎭 Playwright-PHP + Symfony hands the request straight to your Symfony kernel - so you get container access, PHP exception catching, DAMA rollbacks and ParaTest. From a real browser. 🤯 symfonycasts.com/blog/playwri...
symfonycasts.com
Playwright-PHP Changes the Game for Symfony Testing
Real browser. Real JavaScript
063
SymfonyCasts @symfonycasts.com · 27/08/2026
🔐 Symfony Security Basics #17 Let's protect our login form from brute-force attacks! We'll enable Symfony's login throttling, see what happens when we trip the limiter, then dig into its configuration and how it works. Delightful nerdery!
symfonycasts.com
Limiting Login Attempts
Enables Symfony login throttling to limit failed login attempts, explains the required RateLimiter dependency and cache-backed storage, and shows how the default per-IP/per-username and global IP limits...
011
SymfonyCasts @symfonycasts.com · 25/08/2026
🔐 Symfony Security Basics #16 User impersonation is super useful... until you forget you're impersonating someone! Let's make it painfully obvious when we're switched to another user and add an easy way to exit.
symfonycasts.com
Exiting Impersonation & IS_IMPERSONATOR
Adds a visible production indicator for Symfony user impersonation and provides a dedicated way to exit impersonation, including redirecting back to the admin user list afterward.
011
SymfonyCasts @symfonycasts.com · 24/08/2026
Rewind ⏪ Cosmic Coding with Symfony #2 A new Symfony project is... only about 15 files 🤯! Let's get to know our tiny new app, meet the only 2 directories we care about & get PhpStorm set up & ready for coding. symfonycasts.com/screencast/s...
symfonycasts.com
Getting to Know our Tiny Project
Introduces the tiny Symfony 7 project structure, how dependencies are installed via Composer and vendor/, and how to prepare PhpStorm with the Symfony plugin before writing any code.
000
SymfonyCasts @symfonycasts.com · 20/08/2026
🔐 Symfony Security Basics #15 Need to debug a problem from a user's perspective? Let's enable Symfony's user impersonation feature so admins can temporarily switch to another user without ever knowing their password.
symfonycasts.com
Impersonating Users with switch_user
Impersonation with switch_user lets an admin temporarily log in as another user, and this chapter shows how to enable it in Symfony security, expose switch links in a user admin CRUD, and route the impersonated...
011
SymfonyCasts @symfonycasts.com · 19/08/2026
Rewind ⏪ Cosmic Coding with Symfony #1 Cosmic Coding with Symfony (fully compatible with Symfony 8). Let’s build something beautiful, modern & love the process! symfonycasts.com/screencast/s...
symfonycasts.com
Setting up our Symfony App
Sets up a fresh Symfony 7 project from scratch using the Symfony CLI, verifies local system requirements, and starts the built-in development web server so the new app can be opened in a browser.
000
SymfonyCasts @symfonycasts.com · 18/08/2026
🔐 Symfony Security Basics #14 Hiding an action a user can't access is good UX, but it's not security! Let's enforce our voter permissions in the controller, then give admins the power to bypass them.
symfonycasts.com
Denying Access with a Voter
Introduces Symfony voters as the mechanism for denying or allowing access based on custom authorization logic beyond simple roles.
011
SymfonyCasts @symfonycasts.com · 17/08/2026
Doctrine lazy objects used to rely on generated proxy classes that extended your entities. PHP 8.4 makes them native. Same lazy-loading magic - fewer workarounds - and your entities can finally be "final". 🎉 See how lazy objects work 👉 youtu.be/X0HhrOnkGlc
youtu.be
Doctrine Native Lazy Objects Explained
Doctrine uses lazy objects to avoid loading related entities until you actually need their data. Previously, Doctrine generated special proxy classes that extended your entities. With PHP 8.4 and DoctrineBundle 3, PHP can handle lazy objects natively - no generated proxy classes required. The practical payoff? Your relationships still load only when accessed, but your entities can finally be marked as final. Watch the full SymfonyCasts course 👉 https://symfonycasts.com/screencast/symfony8-upgrade/doctrine
021
SymfonyCasts @symfonycasts.com · 14/08/2026
🔐 Symfony Security Basics #13 Roles are great, but sometimes permissions need to be more precise. Let's create a custom voter to decide whether the current user can edit or delete a specific object.
symfonycasts.com
Creating a Custom Voter
Introduces the idea of creating a custom Symfony security voter to make authorization decisions beyond the built-in roles system.
011
SymfonyCasts @symfonycasts.com · 13/08/2026
Rewind ⏪ Doctrine Queries #16 We're wrapping up the update to our Doctrine Queries tutorial with a more complex GROUP BY query. We select objects *and* extra data all at once... to reduce our page queries down to 1! symfonycasts.com/screencast/d...
symfonycasts.com
Using GROUP BY to Fetch & Count in 1 Query
Use a JOIN + GROUP BY + COUNT() query in Doctrine to fetch categories and each category’s fortune-cookie count in one database query instead of one query per category.
000
SymfonyCasts @symfonycasts.com · 12/08/2026
Rewind ⏪ Doctrine Queries #15 Ever run into an SQL function that Doctrine didn't support - like MySQL's RAND? Those may not work out-of-the-box (and b/c of a good reason), but they're easy to use thanks to the beberlei/DoctrineExtensions library! symfonycasts.com/screencast/d...
symfonycasts.com
Using RAND() or Other Non-Supported Functions
Adds support for database-specific DQL functions like RAND() so Doctrine can randomize query order, then uses that custom function to return related FortuneCookie records in random order without…
000
SymfonyCasts @symfonycasts.com · 11/08/2026
One of Symfony's * coolest * security features: 1) Users log in 2) Symfony checks their password hash. 3) Old algorithm? Rehash and save automatically 🔐 Automatic security upgrades over time! youtu.be/Bu8ZDbXAsq8
youtu.be
Symfony Password Upgrading Explained
Symfony can automatically upgrade old password hashes as users log in 🔐 When a user successfully authenticates, Symfony checks whether their stored password hash uses an outdated algorithm. If it does, Symfony rehashes the submitted plain text password with the current hasher and saves the new hash. No password reset needed. No user interruption. Just stronger hashes over time. Check out the full course 👉 https://symfonycasts.com/screencast/symfony8-security
011
SymfonyCasts @symfonycasts.com · 07/08/2026
Rewind ⏪ Doctrine Queries #14 Using the WHERE IN () with Doctrine: super easy... once you see the right syntax (hint: the correct way is easier than normal SQL!) symfonycasts.com/screencast/d...
symfonycasts.com
WHERE IN()
Extends the CategoryRepository::search() query so a search term like "pets love" can match categories word-by-word using IN(), instead of only matching the whole string with LIKE.
000
SymfonyCasts @symfonycasts.com · 06/08/2026
Rewind ⏪ Doctrine Queries #13 Can you *globally* modify *every* query to a table in Doctrine... no matter how that query is made! Yup! Say hello to the "Filters" system. symfonycasts.com/screencast/d...
symfonycasts.com
Filters: Automatically Modify Queries
Doctrine filters let you automatically append a global SQL condition to queries for a specific entity, solving the problem of repeatedly filtering out discontinued FortuneCookie records everywhere in…
000
SymfonyCasts @symfonycasts.com · 05/08/2026
"Remember Me" is convenient. It's also the reason many websites ask you to re-enter your password before changing your email address, password, or other sensitive settings. There's a good security reason for that 🔐 youtu.be/j2s_xZgYNss
youtu.be
Why "Remember Me" Isn't Fully Authenticated
Checking "Remember Me" keeps users logged in, but that doesn't mean they're fully authenticated. A remembered user is less trustworthy than someone who just entered their password. That's why sensitive actions - like changing an email address or password - often require you to authenticate again. It's a small distinction that makes a big difference for your application's security. Watch the full SymfonyCasts lesson 👉 https://symfonycasts.com/screencast/symfony8-security/authentication-attributes
011
SymfonyCasts @symfonycasts.com · 04/08/2026
🔐 Symfony Security Basics #12 Fetching the current user is easy. Fetching it elegantly is even better. Let's compare a few approaches and finish with the expressive #[CurrentUser] attribute.
symfonycasts.com
Fetching the User in Services/Controllers
Shows three ways to fetch the currently logged-in user in Symfony—via AbstractController::getUser(), the Security service, and controller argument resolvers—and how to make the result type-safe so...
011
SymfonyCasts @symfonycasts.com · 03/08/2026
Rewind ⏪ Doctrine Queries #12 One of my *favorite* systems in Doctrine: Criteria. Keep using your lazy relationships - $spaceCat->getPlanetsExplored() - but tell Doctrine to filter them in the database. Combined with fetch: EXTRA_LAZY, this gets CRAZY cool. symfonycasts.com/screencast/d...
symfonycasts.com
Criteria: Filter Relation Collections
Use Doctrine Criteria to filter a relation collection so a Category can expose only “current” FortuneCookie records, hiding those marked discontinued without writing a separate controller query.
000
SymfonyCasts @symfonycasts.com · 31/07/2026
Rewind ⏪ Doctrine Queries #11 You can't normally reuse parts of a query easily between multiple queries. But you can with Doctrine, the query builder and nice organization inside your repository classes! symfonycasts.com/screencast/d...
symfonycasts.com
Reusing Queries in the Query Builder
Refactors repeated CategoryRepository query logic into reusable QueryBuilder helper methods, then makes those helpers optionally create their own builder so multiple query fragments can be composed…
000
SymfonyCasts @symfonycasts.com · 30/07/2026
A cautionary tale for web developers: If a request changes state, it should never be a GET. Browsers, crawlers, and link previewers are allowed to make GET requests automatically. The garage door story is worth hearing... 😅 youtu.be/A4ujMeiG_v8
youtu.be
A Cautionary Tale About GET Requests
A cautionary tale for every web developer. Someone built a smart garage door controller with a GET endpoint that toggled the door. Sounds convenient... until a browser, crawler, or link preview decided to "help" by making the request automatically. If a request changes state, it should never be a GET. Watch the full SymfonyCasts lesson 👉 https://symfonycasts.com/screencast/symfony8-security/logout-csrf
011
SymfonyCasts @symfonycasts.com · 29/07/2026
🔐 Symfony Security Basics #11 Our User class is a Doctrine entity, which means it can have normal Doctrine relationships. Let's add one and use it to personalize our application.
symfonycasts.com
User Doctrine Relationship
On our app's homepage, we have the concept of "MyShip". It's intended to be the current user's starship
011
SymfonyCasts @symfonycasts.com · 28/07/2026
TailwindBundle 1.0 is here! :tada: Add Tailwind CSS to your Symfony + AssetMapper app, with no Node required. A huge thank you to everyone who contributed, reported issues, and helped us reach 1.0! Check out the release: github.com/SymfonyCasts...
github.com
Release v1.0.0 · SymfonyCasts/tailwind-bundle
What's Changed Remove deprecation layer by @kbond in #130 Remind users to clear the cache after config changes by @kbond in #136 Authenticate the GitHub API call to avoid rate limiting by @Amoifr ...
061
SymfonyCasts @symfonycasts.com · 27/07/2026
🔐 Symfony Security Basics #10 Why assign users five roles when one will do? Let's use Symfony's role hierarchy to inherit permissions, then secure an entire admin section with `access_control`.
symfonycasts.com
Role Hierarchy & Access Control
Did you know roles can have children? Yep! And a parent role inherits all the child roles. This is called role hierarchy
011
SymfonyCasts @symfonycasts.com · 24/07/2026
Rewind ⏪ Doctrine Queries #10 If a query gets super complex, there's no need to force it into a query builder or DQL. Write raw SQL query and execute it through Doctrine. Let's do it! symfonycasts.com/screencast/d...
symfonycasts.com
Raw SQL Queries
Shows how to bypass Doctrine ORM/QueryBuilder and run raw SQL through Doctrine DBAL’s Connection when a query is too awkward to express in QueryBuilder, then fetch and hydrate the result into a…
000
SymfonyCasts @symfonycasts.com · 23/07/2026
🔐 Symfony Security Basics #9 Let's compare a few different ways to protect a page with a custom user role. Then we'll follow the login flow to access it and fix a sneaky Turbo gotcha along the way!
symfonycasts.com
User Roles
Let's dive deeper into user roles and how they can be used to control access to different parts of your application. We have this link to our "/parts" page, which lists a bunch of Starship parts
021
SymfonyCasts @symfonycasts.com · 21/07/2026
🔐 Symfony Security Basics #8 A remembered login isn't the same as a fresh login. Let's explore Symfony's authentication attributes and see how they can help protect sensitive actions.
symfonycasts.com
Authentication Attributes
Symfony’s special authentication attributes let you distinguish between public, remembered, and fully authenticated users, so you can protect sensitive actions more precisely than with roles alone.
011
SymfonyCasts @symfonycasts.com · 20/07/2026
Let's take a tour through the internals of Brontie, our AI assistant, we'll take a peek into how it actually works inside SymfonyCasts! 🦕 🤖 symfonycasts.com/blog/brontie...
symfonycasts.com
How We Built Brontie your AI Assistant
Brontie is a new AI assistant for SymfonyCasts. Learn how we built it, how it works, and how you can get involved
011
SymfonyCasts @symfonycasts.com · 17/07/2026
Rewind ⏪ Doctrine Queries #9 Did you know you could select fields from Doctrine and hydrate them into a "NEW MyDtoClass()" right inside your query? Let's take this lesser-known Doctrine feature for a ride! symfonycasts.com/screencast/d...
symfonycasts.com
SELECTing into a New DTO Object
Doctrine can hydrate a custom DTO directly from a SELECT query using NEW, so a repository can return a strongly typed object instead of an associative array for query-specific summary data.
000
SymfonyCasts @symfonycasts.com · 16/07/2026
Rewind ⏪ Doctrine Queries #8 Let's select more and more and more specific fields and see what kind of trouble we can get into! To fetch multiple columns in 1 row, we'll use getSingleResult(). symfonycasts.com/screencast/d...
symfonycasts.com
Selecting Specific Fields
Shows how to extend a Doctrine query to return specific scalar fields alongside aggregates, then switch from getSingleScalarResult() to getSingleResult() so the controller can receive an associative…
001
SymfonyCasts @symfonycasts.com · 15/07/2026
Me: "Which password hashing algorithm should I choose?" Symfony: "Don't worry, I've got this." 🔐 ✨ youtu.be/dizl8aIqhCo
youtu.be
Symfony's Smart Password Hasher
Symfony has a password hasher setting called auto and it's kind of magical ✨. Instead of choosing a specific hashing algorithm yourself, Symfony automatically uses the strongest supported option available. Even better, it can still verify passwords created with older algorithms, so existing users keep logging in normally while new passwords get the latest protection. One more reason to keep your Symfony version up to date 🚀 Watch the full course 👉 https://symfonycasts.com/screencast/symfony8-security
011