
SymfonyCasts ๐บ๐ฆ
@SymfonyCasts
Followers
8K
Following
348
Media
435
Statuses
3K
Injecting Unicorns and Rainbows back into learning PHP // The official way to learn Symfony: https://t.co/9eMhkJPzhF
Grand Rapids, MI
Joined December 2011
Even if you're developing bundles locally, you'll still need to install them with composer. Installation is a little different... but in a good way! We'll even stumble upon a hidden Symfony Flex feature ๐
symfonycasts.com
We have a bundle "package" and bundle class, and even though it lives within our app, we still need to "install" it. This is handled with Composer like normal but the method is a little different
0
0
4
A bundle requires just one thing: a bundle class - the nerve center of your bundle. Let's create one, right after we fix a little quirk when working with multiple namespaces in the same project.
symfonycasts.com
We have a home for our bundle within our app. And, we've set up it's "composer
0
1
7
๐จ New course alert: Reusable Bundles ๐ฆ! Bundle development received a facelift in Symfony 6. Letโs check this out by creating a real, usable bundle that weโll eventually push to Packagist for all to enjoy. Step 1: Initialize our bundle!
0
1
8
If a message fails repeatedly, instead of discarding it forever, let's send it to... the "failure transport"! Let's get this set up & learn how to find out exactly what advanced options each transport has. #Symfony
symfonycasts.com
We now know that each message will be retried 3 times - which is configurable - and then, if handling it *still* fails, it will be "rejected"... which is a "queue" word for: it will be removed from...
0
0
8
Time to look deeper at Messenger's retry settings & more advanced transport config. Retries have an exponential delay built-in to help overcome temporary failures. And of course, you can control all of this. #Symfony
symfonycasts.com
By default, a message will be retried three times then lost forever. Well... in a few minutes... I'll show you how you can *avoid* even *those* messages from being lost
0
1
10
Oh no! You sent your message to a transport/queue, but when it was handled (due to a temporary connection issue) an exception was thrown! Is it lost forever? Nope - Messenger automatically retries it. Let's see retries in action! #Symfony
symfonycasts.com
When you start handling things asynchronously, thinking about what happens when code fails is even *more* important! Why? Well, when you handle things synchronously, if something fails, typically,...
0
1
13
With deep sadness, we share that Ryan Weaver โ co-founder of SymfonyCasts, father, husband, beloved teacher, and friend โ has passed away after a long and courageous journey with brain cancer.
symfonycasts.com
With deep sadness, we share that Ryan Weaver โ co-founder of SymfonyCasts, father, husband, beloved teacher, and friend โ has passed away after a long and courageous journey with brain cancer.
3
24
114
Symfony messenger is all about dispatching "messages". But did you know that you can also wrap your message in an Envelope & attach extra config via stamps? Let's use a stamp to *delay* a message *and* see what stamps are added internally.
symfonycasts.com
We just got a request from Ponka herself... and when it comes to this site, Ponka is the boss. She thinks that, when a user uploads a photo, her image is actually being added a little bit *too*...
0
1
9
What happens if *part* of our handler fails? This is nothing new.... unless *some* of your handler is async. Let's route our second message to be async & learn some advanced features of message routing #Symfony
symfonycasts.com
We just broke our image deleting process into smaller pieces by creating a *new* command class, a new handler and *dispatching* that new command from *within* the handler! This... technically isn't...
0
1
6
Half of the work for deleting an image in our app must happen now... but half could happen later. The solution? Split the command into 2 & dispatch from *within* the handler. We're breaking things down into smaller pieces to gain more control. #Symfony
symfonycasts.com
Deleting an image is still done synchronously. You can see it: because I made it *extra* slow for dramatic effect, it takes a couple of seconds to process before it disappears
0
0
5
Let's update our Messenger message class to hold the entity id instead of the entire object. That'll fix a bug and follow a nice rule: make your message as small as possible. Bonus: we'll start learning to fail gracefully & see retries in action #Symfony
symfonycasts.com
Suppose you need your friend to come over and watch your dog for the weekend - let's call her Molly. So you write them a message explaining all the details they need to know: how often to feed Molly,...
0
0
5
A quick aside about Messenger, serializing Doctrine entities & (nerd-alert) the identity map! A fun look into a bug in our app and how Doctrine works internally. #Symfony
symfonycasts.com
We've got a strange issue: we know that "AddPonkaToImageHandler" is being called successfully by the worker process.... because it's *actually* adding Ponka to the images! But, for some reason......
0
0
6
How can we *consume* messages from the queue asynchronously? By running Symfonyโs worker command: php bin/console messenger:consume Dispatching new messages and watching them get handled async automatically? Gorgeous! https://t.co/Kb9LYxOKU5
0
0
4
Say hello to Messenger transports: the key system that allows you to send message to a queue instead of handling them immediately. Letโs get the Doctrine transport set up, route some messages there and see what it all looks like in the database! #Symfony
https://t.co/oHuVytOWhO
0
1
10
Weโre putting messenger to work, refactoring a controller down to 2 lines! Thatโs thanks to a new command class, a new handler and the debugging superpowers of debug:messenger... when I mess up #Symfony
https://t.co/2xqyZdp8te
0
1
8
The command (message) class and handler inside Messenger are a team: the message class holds *whatever* data you need to pass around while the handler uses that info (+autowired services) to do the work! Itโs refreshingly... simple. #Symfony
https://t.co/U7DbTYvybz
0
1
9
Letโs get to the heart of messenger! Create a message class, a handler class, *link* them together, and dispatch to the bus. Oh... and weโll explain what the heck a โcommand busโ *is* in the first place. #Symfony
https://t.co/Xnag70gCE3
0
1
10
We've successfully pushed our English translations up to @Crowdin. Merci beaucoup! now, let's automatically translate and pull them back down!
symfonycasts.com
Our "Space Bar" project on Crowdin is all set up and configured for our app's locales. Let's push up our translations! At your terminal, run: """terminal symfony console translation:push """ Ok, all...
0
1
8
For a course about translations, we really havenโt done much "translating" yet. Thatโs kinda important! Symfony has integrations with a few different Translation Provider services. Letโs look at @Crowdin, and see how it works!
symfonycasts.com
So far, we've mostly focused on translating our site from English to... English... What about French and Spanish? We've talked a bit about how we can manually send our "messages.en
0
3
9