Chapters
48 Chapters
|
5:05:05
|
Login to bookmark this video
-
Course Code
Subscribe to download the code!Compatible PHP versions: ^7.1.3
Subscribe to download the code!Compatible PHP versions: ^7.1.3
-
This Video
Subscribe to download the video!
Subscribe to download the video!
-
Subtitles
Subscribe to download the subtitles!
Subscribe to download the subtitles!
-
Course Script
Subscribe to download the script!
Subscribe to download the script!
Scroll down to the script below, click on any sentence (including terminal blocks) to jump to that spot in the video!
Subscribe to jump to this part in the video!
Keep on Learning!
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
Este tutorial está construido con Symfony 4.3, pero funcionará bien en Symfony 4.4 o 5.
What PHP libraries does this tutorial use?
// composer.json
{
"require": {
"php": "^7.1.3",
"ext-ctype": "*",
"ext-iconv": "*",
"composer/package-versions-deprecated": "^1.11", // 1.11.99
"doctrine/annotations": "^1.0", // v1.8.0
"doctrine/doctrine-bundle": "^1.6.10", // 1.11.2
"doctrine/doctrine-migrations-bundle": "^1.3|^2.0", // v2.0.0
"doctrine/orm": "^2.5.11", // v2.6.3
"intervention/image": "^2.4", // 2.4.2
"league/flysystem-bundle": "^1.0", // 1.1.0
"phpdocumentor/reflection-docblock": "^3.0|^4.0", // 4.3.1
"sensio/framework-extra-bundle": "^5.3", // v5.3.1
"symfony/console": "4.3.*", // v4.3.2
"symfony/dotenv": "4.3.*", // v4.3.2
"symfony/flex": "^1.9", // v1.21.6
"symfony/framework-bundle": "4.3.*", // v4.3.2
"symfony/messenger": "4.3.*", // v4.3.4
"symfony/property-access": "4.3.*", // v4.3.2
"symfony/property-info": "4.3.*", // v4.3.2
"symfony/serializer": "4.3.*", // v4.3.2
"symfony/validator": "4.3.*", // v4.3.2
"symfony/webpack-encore-bundle": "^1.5", // v1.6.2
"symfony/yaml": "4.3.*" // v4.3.2
},
"require-dev": {
"easycorp/easy-log-handler": "^1.0.7", // v1.0.7
"symfony/debug-bundle": "4.3.*", // v4.3.2
"symfony/maker-bundle": "^1.0", // v1.12.0
"symfony/monolog-bundle": "^3.0", // v3.4.0
"symfony/stopwatch": "4.3.*", // v4.3.2
"symfony/twig-bundle": "4.3.*", // v4.3.2
"symfony/var-dumper": "4.3.*", // v4.3.2
"symfony/web-profiler-bundle": "4.3.*" // v4.3.2
}
}
21 Comments
For all ya windows-dudes outside: https://dev.to/rezende79/how-to-install-amqp-extension-for-php-7-4-on-windows-10-108d
While i am creting the instance for Rabbitmq on https://api.cloudamqp.com/
It was generating the connection URL like "amqps://siyjukin:8pBsS8JxGr..." host instead of "amqp://siyjukin:8pBsS8JxGr9..."
Because of this i was geting the below error
No transport supports the given Messenger DSN "amqps://vdfhbywr:qfdJGzTGWS...".
Hey Balu,
Unfortunately your comment got spam filter, I just approved it. So, after you changed it from "amqps" to "amqp" - everything works fine now?
Cheers!
Yep,this is solution you should note it.
Hello! How to xdebug AMQP message handler? Breakpoint not working, however if i use doctrine message handler (i previously comment in messenger.yaml line with message) xdebug work perfect P.s. I use PHPStorm with Xdebug
Hey @Mepcuk ,
I think you can use
dump()debug function inside the message handle, run the Messenger worker withsymfony console messenger:consume, do something to trigger that message creation and wait when the Messenger handles it, then open the console where you you're running themessenger:consumeto see the dump in the console :) Thanks to the VarDump component the dump will be well-formatted in the console output :)Another way to debug it - temporarily add
MESSENGER_TRANSPORT_DSN=sync://to your.env.local(make sure no moreMESSENGER_TRANSPORT_DSNdeclarations there that will overwrite the var). Thanks to this message the Messenger will work sync instead of async, i.e. it will run the message handler in the same request and so you will see the dump on the Symfony's WDT. Or usedd()to stop the execution and see the dump right on the page :)I hope this helps!
Cheers!
Hello!
I was wondering if you have a good solution for production and development apps?
I have RabbitMQ on a server and supervisor process for handling Worker for the app from main domain (production). On the same server, on different domain a have a development version of the app. In order to user RabbitMQ there I should add another process for Supervisord with another worker so that it consumes messages from Development app. But actually these are the same messages, sent to the same RabbitMQ instance. So what should I do? Have different names for transport for both Production and Development apps? Any ideas?
Hey Tomasz,
I believe the easiest thing to do is to create another account for dev and use those credentials locally. Otherwise, you'll need to configure Messenger to send your messages to a different RabbitMQ exchange.
I hope it helps. Cheers!
Hi, when my consumer consumes the message from rabbitMQ I get an exception:
[Symfony\Component\Messenger\Exception\MessageDecodingFailedException]
Could not decode message using PHP serialization: ��-.
Is it because the message was created and dispatched by hand in rabbitmq UI and not with symfony messenger?
Hey Daniel W.!
Woh! That's very interesting! When you dispatched the message by hand, what format did you use for the data? Was it JSON? Did you actually try to serialize a PHP object and "paste" it in?
If you used JSON, then the general answer of how to make Messenger understand custom created message bodies is a a bit later in the tutorial: https://symfonycasts.com/sc...
If you pasted a serialized object by hand, the answer is probably that you should first base64_encode the PHP class before sticking it into the body. PHP serialization creates binary characters... which don't play well in some transports. That's why we base64_encode when we encode a message - https://github.com/symfony/... - and base64_decode when we read it back in (well, technically, the decoding is optional): https://github.com/symfony/...
Let me know if that helps!
Cheers!
Ahh I was too unpatient experimenting again. Yea I need a custom serializer for handling external messages.
I kinda expected it I just thought that if no serializer is defined the messenger would handle the content as pain text.
Thanks a lot.
hello , i used amqp cloud , create an instance and add its url in my messenger transport dsn, i got this error:
No transport supports the given DSN:***,
is there extra econfiguartion to add in my app ?
thanks in advance
Hey!
Are you in Symfony 5.1? The Ampq transport was move to its own library, read more info here https://symfony.com/doc/current/messenger.html#amqp-transport
if thats the case just install
composer require symfony/amqp-messengerCheers
While i am creting the instance for Rabbitmq on https://api.cloudamqp.com/
It was generating the connection URL like "amqps://siyjukin:8pBsS8JxGr..." host instead of "amqp://siyjukin:8pBsS8JxGr9..."
Because of this i was geting the below error
No transport supports the given Messenger DSN "amqps://vdfhbywr:qfdJGzTGWS...".
Hey Balu
Sorry for late reply, your comment was somehow missed in multiple comments =( So have you tried to remove this letter "s" from url? and use it?
Cheers!
My error was
You cannot use the "Symfony\Component\Messenger\Transport\AmqpExt\Connection" as the "amqp" extension is not installed.I'm using Docker with php:7.3.8-fpm-alpine3.10.
I added to my Dockerfile something equvalent to:
<br />RUN apk add rabbitmq-c rabbitmq-c-dev<br />RUN pecl install amqp<br />RUN docker-php-ext-enable amqp<br />RUN apk del --purge rabbitmq-c-dev<br />Sould you have the same problem.
Cheers
Hi julien_bonnier I am having the same issue, did you solve it? Thx
That was a while ago, but I'm pretty sure I was posting my solution and not just asking for help. Are you using Docker? If so, did you try to add the pecl package and enable the extension as mentioned in my previous post?
Hey julien_bonnier!
Hmm, I'm not sure! Here's what I would check. Open any page in your site, wait for the web debug toolbar to open, hover over the Symfony version on the bottom right, and then click
View phpinfo(). This will show you the phpinfo() details. Is AMQP here? My guess is that it is not here... and so there's somethiung wrong with your Docker setup. It could be that your web browser is using a different php container (sometimes people have 2 containers for php - one for the cli and one for php-fpm) or something else.Cheers!
Hi, I am having the same issue, did you solve it? Thanx
Hey Henry Vallenilla!
What operating system are you on and how do you have PHP installed? Are you using Docker? Installing PHP extensions is different for every setup, unfortunately :p.
Cheers!
"Houston: no signs of life"
Start the conversation!