The Symfony Request class interactive cheatsheet

Published on 2019-01-29 • Modified on 2019-01-30

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 own one so you can test with different parameters. It will therefore save you manual dump() calls. 😉 Let's go! 😎

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 runs the most recent Symfony version. Below, the current used versions:

  • Symfony 4.2.6
  • PHP 7.2

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 obviously 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).


» Call to action

Did you like this post? You can help me back in several ways: (use the Tweet on the right to comment/contact me )

  • Report any error/typo.
  • Report something that could be improved.
  • Like and retweet!
  • Follow me on Twitter
  • Subscribe to the RSS feed.

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

COil