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.

Configuration

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 6.4.12
  • PHP 8.3

Let's go!

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.

Results will be displayed only if the URL is valid.

Results

Function name Parameters Output Doc
≪ fct.name ≫() ≪ fct.parameters ≫ ≪ getResult(fct) ≫ API

 Request API  Symfony HTTP fundamentals

» Published in "A week of Symfony 631" (28 January - 3 February 2019).

  Work with me!


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 )

Thank you for reading! And see you soon on Strangebuzz! 😉

COil