The Symfony Request class interactive cheatsheet
Published on 2019-01-29 • Modified on 2020-04-10
In this post, we will review one of the most used and useful service (in fact it's a value object) provided by Symfony which is the Request service Is is part of the HttpFoundation component. Symfony is indeed a "Request/Response" framework. It will be interactive, that means that you will be able to change the URL used in the examples and provide your one so you can test with different parameters. It will, therefore, save you manual
dump() calls. 😉
Let's go! 😎
- Edit [2020-04-10]: Update for Symfony 5.
As this blog post directly uses this Symfony project and is unit tested, you are sure it is up to date, and, that is running the most recent Symfony version. Below, the current used versions:
- Symfony 5.3.0
- PHP 7.4
By default, we will use the current URL of this post. Enter a new URL, add or modify parameters to see the changes on the tested functions. Some of these functions will only work at the first access of this post because in this case, it has the full server context. (The PHP
$SERVER global variable). For example, if you hit the refresh button, you will see that the line with
getScriptName() will disappear as this value can't be guessed.
||≪ fct.parameters ≫||≪ getResult(fct) ≫||API|
» Published in "A week of Symfony 631" (28 January - 3 February 2019).
Call to action
Did you like this post? You can help me back in several ways: (use the Tweet on the right to comment or to contact me )
- Report any error/typo.
- Report something that could be improved.
- Like and retweet!
- Follow me on Twitter Follow me on Twitter
- Subscribe to the RSS feed.
- Click on the More on Stackoverflow buttons to make me win "Announcer" badges 🏅.
Thank you for reading! And see you soon on Strangebuzz! 😉
[🇬🇧] This is my first #Symfony 2019 blog post. It's quite different from a standard one as it is "interactive". It's a #cheatsheet 🧐 about the #Symfony request class: https://t.co/evTaFnJFv6 Comments and retweets are welcome! 😉 Annual goal: 1/12 (8%) #php #blog #http— Vernet Loïc (@C0il) 30 janvier 2019