Symfony 3.2 request class mini-cheatsheet

Published on 2017-02-28

Hi symfonians !

Once again... such a long time since my last post! (4 years! Yikes!) This is mainly because I have a lot to do with the Symfony projects I actually develop/maintain as a contractor. (3 million users/month). This post is an update of a previous one related to Symfony2. The request class is one of most frequently used in a Symfony project as it is tied (and injected) with controllers.

Considering the following URL:

Here are the results of the different main public methods of the Symfony\Component\HttpFoundation\Request class:

Will produce the following output:

See you. 😉

PS: Note that the fragment (#fragment) part of the URL can't be retrieved server side. But it can be added when generating URLs via the routing service.

Tags: cheatsheet symfony Symfony3