Chapters
25 Chapters
|
2:34:05
|
Login to bookmark this video
-
Course Code
Subscribe to download the code!
Subscribe to download the code!
-
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!
What PHP libraries does this tutorial use?
// composer.json
{
"require": {
"php": ">=8.1",
"ext-ctype": "*",
"ext-iconv": "*",
"knplabs/knp-time-bundle": "^1.18", // v1.19.0
"symfony/asset": "6.1.*", // v6.1.0-RC1
"symfony/console": "6.1.*", // v6.1.0-RC1
"symfony/dotenv": "6.1.*", // v6.1.0-RC1
"symfony/flex": "^2", // v2.4.5
"symfony/framework-bundle": "6.1.*", // v6.1.0-RC1
"symfony/http-client": "6.1.*", // v6.1.0-RC1
"symfony/monolog-bundle": "^3.0", // v3.8.0
"symfony/runtime": "6.4.3", // v6.4.3
"symfony/twig-bundle": "6.1.*", // v6.1.0-RC1
"symfony/ux-turbo": "^2.0", // v2.1.1
"symfony/webpack-encore-bundle": "^1.13", // v1.14.1
"symfony/yaml": "6.1.*", // v6.1.0-RC1
"twig/extra-bundle": "^2.12|^3.0", // v3.4.0
"twig/twig": "^2.12|^3.0" // v3.4.0
},
"require-dev": {
"symfony/debug-bundle": "6.1.*", // v6.1.0-RC1
"symfony/maker-bundle": "^1.41", // v1.42.0
"symfony/stopwatch": "6.1.*", // v6.1.0-RC1
"symfony/web-profiler-bundle": "6.1.*" // v6.1.0-RC1
}
}
14 Comments
Hi Ryan !
Thanks for these great tutorials.
Would there be a reason for Http Client Icon not showing in the debug toolbar ?
My current Sf version is 6.2.6
Thanks,
Marc.
Hey Marc!
Hmm, that's weird - I can't think of a reason! As long as you have the
http_clientenabled (which should happen automatically when you install that package) and the profiler (which you DO have if you are seeing the web debug toolbar), then it should be there. The logic that loads it is here - https://github.com/symfony/symfony/blob/0383b067e947efb3570b2fda8259e582ef3d8f2d/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php#L846-L848 - but that's super deep and complex, so not sure that's helpful. But it basically says what I just said: as long as profiler and http_client are enabled, that web debug toolbar should be there.Oh, actually, there is one other possibility: there were no requests issued during the request by the HTTP client. If that happens, the web debug toolbar icon won't be shown - https://github.com/symfony/symfony/blob/0383b067e947efb3570b2fda8259e582ef3d8f2d/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/http_client.html.twig#L40 - but if you clicked any of the other icons to get into the profiler, I think you would still see an "HTTP Client" section.
Let me know if this helps!
Cheers!
Hi Ryan,
Thanks for your answer.
The fact is I tweaked http_client.html.twig to display {{ collector.requestCount }} value. It stays at 0 though dumping the result of
via dump($response) outputs :
By the way, dumping $response->toArray() outputs the desired array.
Would you have an idea how we can get the valid response content with no request done ?
Would there be an internal cache ?
In composer.json, http-client is version 6.2.6
Kind regards,
Marc.
Hey Marc!
That's some good debugging! Hmm. A few things to check out... though I don't think these are the cause (but I need to check anyways):
A) You are autowiring the HttpClient service the same way we do in the tutorial?
B) Are you actually using the result of the response? I'm asking because the HttpClient is "async". So if you simply made a request, but never used its response, then it's possible that the response hasn't actually finished by the time the profiler collects the data. However, if you are even calling
$response->toArray(), then that makes the code "wait" for the request to finish... and so that would be enough to avoid this.So then, what could the cause be? I'm not sure - it definitely looks weird :/
I'm interested also if:
1) Is this method being called https://github.com/symfony/symfony/blob/0383b067e947efb3570b2fda8259e582ef3d8f2d/src/Symfony/Component/HttpClient/DataCollector/HttpClientDataCollector.php#L44 ?
2) And if so, what does
dd($this->clients)show? It should show at least one HttpClient3) If your controller, if you
dump($httpClient), what does it look like? It should be aTraceableHttpClient. I'm pretty sure it IS because you're getting back aTraceableResponse.Let me know what you find out :).
Cheers!
Thanks Ryan,
for questions A and B, I can say answer is Yes. Here's the code :
For points
I'm really sorry to bother you with this.
Thanks!
Huh... so everything, so far, seems to be working 100% correctly!
So. you have confirmed that
lateCollect()is called (2x in fact... that may be normal - I'm not sure, I'm not familiar enough with that system) - https://github.com/symfony/symfony/blob/0383b067e947efb3570b2fda8259e582ef3d8f2d/src/Symfony/Component/HttpClient/DataCollector/HttpClientDataCollector.php#L44And we also know that
$this->clientcontains 1 item. So next I would be interested in what$traceslooks like - https://github.com/symfony/symfony/blob/0383b067e947efb3570b2fda8259e582ef3d8f2d/src/Symfony/Component/HttpClient/DataCollector/HttpClientDataCollector.php#L51If there is at least 1 item in
$traces, then$this->data['request_count']would be more than 0. And THEN we should see the icon - thanks to https://github.com/symfony/symfony/blob/0383b067e947efb3570b2fda8259e582ef3d8f2d/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/http_client.html.twig#L40Actually, in https://github.com/symfony/symfony/blob/0383b067e947efb3570b2fda8259e582ef3d8f2d/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/http_client.html.twig#L40 - you might also try a
dump(collector)(outside of any if statements) to make sure this is being called AND whatcollectorlooks like.So, there is a still a mystery here... but we're circling closer and closer to it :).
Cheers!
Hi Ryan,
Thanks for your answer and sorry for the late reply.
Dumping $trace doesn't provide any info, as it gives an empty array.
The most interesting part comes from dumping collector in http_client.html.twig :
No clients in clients[], but clients in the #data property.
Would you have an idea ?
If it looks too complicated, we can forget about my question.
Thanks anyway Ryan !
Dang! I am at a loss! How could that
clientsproperty be an empty array... and yet$datagot populated! Haha, indeed - without being able to play with the code first-hand, I think this will remain a mystery (though, you were an excellent debugging partner). It's possible there is some problem introduced in newer versions of Symfony... or just something bizarre with your setup for some reason. If you DO every happen to find out (maybe it goes away randomly), let me know.Cheers!
Thanks again Ryan !
I'll let you know in case I solve this stuff...
By the way, congrats to your team : the tutorials are excellent as well as your answers !
Regards,
Marc.
I am having the same issue, also Symfony 6.2.6
Ah, I can repeat it too! This was a bug introduced unintentionally during a CVE security release. The fix has already been merged - https://github.com/symfony/symfony/pull/49301 - it looks like that should land in 6.2.7 when it's released.
Thanks Yard for speaking up - as soon as 2 users had the problem, I knew something must have been wrong!
Hi Ryan !
Why does my web debugging tool not have httpclient??
the bug image link!!
http://kfc.insideria.vip/bug1.png
Hey Jamey-C,
Difficult to say... are you sure you're in the same Symfony environment? I mean, if you tun that code in a Symfony test mode but then look at the latest profile in the browser in Symfony dev mode - you will not see it. Also, I see you're sending a GET request to the "http://kfc.insideria.vip/mixes.json" but on the screenshot I see you're looking at the profile of http://c.com/browse page - those seems like 2 different pages for me :) Btw, that mixes.json file is a real file in your public/ dir? If so - that makes sense you don't see anything in your profiler, because physical files are just served as is, you will only see the requests that are handled by Symfony core in your profiler, i.e. requests to your Symfony controller endpoints, not requests to the physical files.
I hope this helps!
Cheers!
Hi Ryan,
Thanks for these wonderful tutorials.
If Laravel is built on top of many Symfony's bundles and even both have their own cache systems I wonder how is possible that some benchmark on the internet gave a better performance to Laravel? Exactly the conclusions of many of them are: "The average loading time for websites on Laravel is about 60 milliseconds, while Symfony's load time is about 250 milliseconds"
Thank you, kind regards.
"Houston: no signs of life"
Start the conversation!