SymfonyCasts's Avatar

SymfonyCasts

@symfonycasts.com

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

703
Followers
5
Following
194
Posts
02.11.2024
Joined
Posts Following

Latest posts by SymfonyCasts @symfonycasts.com

Preview
Query Bus The last type of bus that you'll hear about is... the double-decker tourist bus! I mean... the query bus! Full disclosure... while I *am* a fan of waving like an idiot on the top-level of a tourist…

Rewind ⏪ Symfony Messenger #32
We've talked about command & event buses already. Now it's time to talk about the final type: a school bus! I mean, a query bus!? symfonycasts.com/screencast/m...

06.03.2026 09:01 👍 0 🔁 0 💬 0 📌 0
Preview
Doctrine Transaction & Validation Middleware We're now using both a command bus pattern, where we create commands and command handlers, and the event bus pattern: we have our first event and event handler. The difference between a command and…

Rewind ⏪ Symfony Messenger #31
Ready to see a cool Symfony services config trick? We use auto-registration, sub-directories and tags to bind our command handlers *only* to the command bus & our event handlers *only* to the event bus. An optional, but geeky-fun step! symfonycasts.com/screencast/m...

05.03.2026 09:00 👍 0 🔁 0 💬 0 📌 0
Preview
Doctrine Transaction & Validation Middleware We're now using both a command bus pattern, where we create commands and command handlers, and the event bus pattern: we have our first event and event handler. The difference between a command and…

Rewind ⏪ Symfony Messenger #30
Messenger has a few other built-in, but optional middleware that we haven't talked about. Let's look into the validation & doctrine_transaction middleware, talk about what each does and why you might (or might not) use them #Symfony symfonycasts.com/screencast/m...

04.03.2026 09:02 👍 0 🔁 0 💬 0 📌 0
Preview
`translate_object` Twig Filter We have our "ObjectTranslator" service fully working. It can be injected and used in PHP code like we're doing in "ArticleController::show()"

Twig loads all extensions on each request - even unused ones. To keep things fast, push heavy logic into a Twig runtime. Pro tip: the runtime can be any service, not just something Twig-specific.
👉 symfonycasts.com/screencast/b...

03.03.2026 09:00 👍 0 🔁 0 💬 0 📌 0
Preview
Messenger vs EventDispatcher If you've ever create an event listener or event subscriber in Symfony, you're creating a "listener" for an event that's dispatched through a service called the "event dispatcher". The purpose of the…

Rewind ⏪ Symfony Messenger #29
If Symfony has an EventDispatcher... and also Messenger is able to dispatch events... what’s the difference between EventDispatcher & Messenger? And when should I use one versus the other? Excellent question! symfonycasts.com/screencast/m...

27.02.2026 09:01 👍 0 🔁 0 💬 0 📌 0
Preview
Dispatching the Event & No Handlers Back in "DeleteImagePostHandler", we need to dispatch our new "ImagePostDeletedEvent" message. Earlier, we created a *second* message bus service

Rewind ⏪ Symfony Messenger #28
We’ve created an “event” and an “event handler”. Let’s finish this by dispatching that into our Messenger-powered event bus. Also: what happens if an event has *no* handlers? In a perfect world... that should be allowed. #Symfony symfonycasts.com/screencast/m...

26.02.2026 09:01 👍 0 🔁 0 💬 0 📌 0
Preview
Creating & Handling Events So... what the heck *is* an event? Let me give you an example. Suppose a user registers on your site

Rewind ⏪ Symfony Messenger #27
Event time! We’ll create our first “event” class for Messenger & corresponding event handler. What’s the difference between an event and a message? Let’s find out! #Symfony symfonycasts.com/screencast/m...

25.02.2026 09:01 👍 1 🔁 0 💬 0 📌 0
Preview
Events & Event Bus Messenger is a "message bus". And it turns out that a "message" is a pretty generic term in computer science

Rewind ⏪ Symfony Messenger #26
We’re on our way to using Messenger as an event bus! Let’s configure a separate bus service for this & see “named autowiring” in action: the system that allows you to autowire different message bus services in different situations symfonycasts.com/screencast/m...

24.02.2026 09:00 👍 0 🔁 0 💬 0 📌 0
Preview
`translate_object` Twig Filter We have our "ObjectTranslator" service fully working. It can be injected and used in PHP code like we're doing in "ArticleController::show()"

When building bundles, not every class is meant to be used by end users. My preference is to mark those as "internal", and "hide" services so they don’t show up during container debugging. Here’s how I do it 👉 symfonycasts.com/screencast/b...

23.02.2026 09:00 👍 1 🔁 0 💬 0 📌 0
Preview
Killing Workers Early & on Deploy Run: """terminal php bin/console messenger:consume --help """ We saw earlier that this has an option called "--time-limit", which you can use to tell the command to run for 60 minutes and then…

Rewind ⏪ Symfony Messenger #25 When you deploy new code to your Symfony app, will your workers see the new code? Not until you restart them! Learn about a command to restart *all* workers, options to make sure workers don't run too long & an updating messages gotcha symfonycasts.com/screencast/m...

16.02.2026 09:01 👍 0 🔁 0 💬 0 📌 0
Preview
Deployment & Supervisor So... how does all of this work on production? It's a simple problem really: on production, we somehow need to make sure that this command - "messenger:consume" - is *always* running. Like, *always*

Rewind ⏪ Symfony Messenger #24 Deploy time! Messenger is delivering messages to our queue... but how do we run our workers on production? If your host doesn't handle it for you, Supervisor will. Let's get this tool set up, kill some workers & watch them restart symfonycasts.com/screencast/m...

13.02.2026 09:00 👍 1 🔁 0 💬 0 📌 0
Preview
Symfony Flex Recipe We left off with this gross user experience when installing our bundle in a Symfony application. Let's create a Symfony Flex recipe to improve this! The recipe will add the required "Translation"…

Want to unlock the power of #Symfony Flex for your own bundles? Learn how to create a "contrib" Flex recipe with us -> symfonycasts.com/screencast/b...

12.02.2026 09:00 👍 0 🔁 0 💬 0 📌 0
Preview
Publish to Packagist and Release Our bundle is now hosted on GitHub and our continuous integration with GitHub Actions is green! To make it installable via Composer, we need to publish it on Packagist. You won't be able to follow…

Have you ever built a PHP package you’re proud of? Well, you should publish it to Packagist so anyone can install and use it with Composer. Here’s a quick tutorial on how to do it -> symfonycasts.com/screencast/b...

11.02.2026 09:02 👍 2 🔁 0 💬 0 📌 0
Preview
CI with GitHub Actions At long last, it's time to share our bundle with the world! First though, we'll add the configuration needed for GitHub Actions to run our tests, static analysis, and verify our coding standards. …

Want every push to your PHP project tested automatically? GitHub Actions makes that easy! Here’s how to get started quickly: symfonycasts.com/screencast/b...

10.02.2026 09:00 👍 1 🔁 0 💬 0 📌 0
Preview
Submitting a Form via GET Right now, we've got a search form. But there's a tiny hiccup

Symfony Form Basics #11
Let’s wrap up our unmapped form by switching it to GET, cleaning up the query string, reading the submitted data, and giving it a Turbo-powered boost ⚡.

06.02.2026 09:01 👍 0 🔁 0 💬 0 📌 0
Preview
Static Analysis with PHPStan While *tests* verify your code works as expected by running it, *static analysis* examines your code without executing it. This helps catch potential issues that tests might miss

Find bugs without even running your code. Use PHPStan to add static analysis to your project and start catching issues your tests miss --> symfonycasts.com/screencast/b...

05.02.2026 09:01 👍 4 🔁 2 💬 0 📌 0
Preview
Forms Without a Data Class We're almost at the finish line of our journey with Symfony Forms. But before we wrap it up, let's dive into something both fun and practical

Symfony Form Basics #10
Symfony form types don’t have to be tied to an entity. Let’s turn a plain HTML form into a Symfony form and explore some other cool options along the way!

04.02.2026 09:01 👍 0 🔁 0 💬 0 📌 0
Preview
Metadata & PHP CS Fixer Bundle coding is done, and tests are passing on all our supported Symfony versions. We're on the home stretch! ## License File Let's add a license file to our bundle

Consistent code style = happier humans reading your code. Install PHP-CS-Fixer and start automating the boring stuff --> symfonycasts.com/screencast/b...

03.02.2026 09:00 👍 1 🔁 1 💬 0 📌 0
Preview
Embracing Entity's CRUD Operations Let's talk about CRUD! No, not the icky stuff, but the *create*, *read*, *update*, and *delete* operations that are the backbone of most admin sections. Instead of spending precious time writing controllers,...

Symfony Form Basics #9
A fully customizable CRUD for an entity in seconds? What a dream! One command gives us the whole UI, then we step in for the fun part: tweaks, fixes, and styling!

02.02.2026 09:01 👍 0 🔁 0 💬 0 📌 0
Stateful vs Stateless CSRF protection in Symfony
Stateful vs Stateless CSRF protection in Symfony A quick guide to stateful vs stateless CSRF protection in Symfony — and how request protection works today. #Symfony #shorts Watch the full video 👉 …

Happy Thursday - here's a quick guide to stateful vs stateless CSRF protection in Symfony — and how request protection works today. #Symfony #shorts
www.youtube.com/shorts/URNBE...

29.01.2026 09:00 👍 2 🔁 1 💬 0 📌 0
Preview
Organizing Form Fields Let's take a moment to discuss the organization of fields in our form, particularly that Notes field sitting right in the middle of everything. Ideally, you'd want the required fields to come first,…

Symfony Form Basics #8 Time for some polish 💅. We’ll reorder fields, customize the layout, and tweak styling directly in Twig. Then handle global form errors and add help text that steers users away from validation errors in the first place. symfonycasts.com/screencast/s...

28.01.2026 14:45 👍 0 🔁 0 💬 0 📌 0
Preview
Validation Constraints In the previous chapter, we installed the Symfony Validator Component and applied our first validation constraint to our form's "name" field. This setup helps us catch errors when we submit an empty form...

Symfony Form Basics #7 Validation isn’t just for form types. We’ll move constraints onto our entities, explore how null values bypass most constraints (and how NotBlank changes that), then wrap things up with CSRF protection!

26.01.2026 09:02 👍 2 🔁 0 💬 0 📌 0
Preview
Testing with the "in-memory" Transport A few minutes ago, in the "dev" environment only, we overrode all our transports so that all messages were handled synchronously. We commented it out for now, but this is *also* something that you…

Rewind ⏪ Symfony Messenger #23
By using Symfony’s in-memory transport, we can short-circuit the message delivery system in the test environment and assert that the *exact* right message was sent. Boom!
symfonycasts.com/screencast/m...

22.01.2026 09:01 👍 0 🔁 0 💬 0 📌 0
Preview
Client-side vs Server-side Validation It's time to talk about form validation. Because just like a starship without shields, a form without validation is impressive to look at... but is only one asteroid away from total disaster

Symfony Form Basics #6 Client-side HTML5 validation is nice… but it’s easy to bypass. Let’s add real server-side validation with the Validator component!

21.01.2026 09:01 👍 0 🔁 0 💬 0 📌 0
Preview
Functional Test for the Upload Endpoint How can we write automated tests for all of this? Well... I have so many answers for that. First, you could unit test your *message* classes

Rewind ⏪ Symfony Messenger #22
How can we unit test our Messenger setup? Since we’re writing great code, we can unit test all of it! Let’s bootstrap a functional test for the upload endpoint on our way to asserting that the message was received by the transport!
symfonycasts.com/screencast/m...

20.01.2026 09:01 👍 0 🔁 0 💬 0 📌 0
Preview
Built-in Symfony Form Themes Okay... it’s finally time. The long-awaited moment where we... add styling to our form

Symfony Form Basics #5
Time to dress our form up for the big dance! We'll apply a built-in form theme, adjust individual field attributes, and improve the `EntityType` user experience. 💅

16.01.2026 09:01 👍 0 🔁 0 💬 0 📌 0
Preview
Handling Messages Sync while Developing I *love* the ability to defer work for later by sending messages to a transport. But, there *is* at least one practical bummer: it makes it a bit harder to actually *develop* and code your app

Rewind ⏪ Symfony Messenger #21
While developing, you *can* run the “messenger:consume” command to handle the messages. *Or*, you can use the “sync” transport and a configuration trick to handle messages *now* and keep life simple. #Symfony
symfonycasts.com/screencast/m...

15.01.2026 09:01 👍 0 🔁 0 💬 0 📌 0
Preview
High Priority Transports The two messages that we we're sending to the "async" transport are "AddPonkaToImage" and "DeletePhotoFile", which handles deleting the physical file from the filesystem. And... that second one isn't…

Rewind ⏪ Symfony Messenger #20
Some messages are more important than others. If your queue gets filled with a mixture of “super important” and “less important” messages, can we tell Messenger which to handle first? Totally! By creating “priority transports” #Symfony
symfonycasts.com/screencast/m...

13.01.2026 09:01 👍 0 🔁 0 💬 0 📌 0
Preview
Multiple Submit Buttons Alright, we've got our "Create" button working like a charm, but what if we want a couple of different workflows: "Create and Close" to save the part and jump back to the list, and "Create and Add Another"...

Symfony Form Basics #4
HTML forms can have more than one submit button - and each can do something different. Symfony wraps this nicely so you can easily see which button was clicked. Let's check it out!

13.01.2026 09:01 👍 0 🔁 0 💬 0 📌 0
Preview
Processing the Submitted Form Alright, we've built, created, rendered, and styled our form. I've given it my all and now our form is ready for submission

Symfony Form Basics #3
We can submit our form… but nothing happens yet! Let’s take the submitted data, save it to the database, redirect, and show the user a success message. And then go grab a snack, you earned it!

09.01.2026 09:01 👍 2 🔁 2 💬 0 📌 0