Backend and Infrastructure

Symfony Controllers

Check your version

This tutorial covers a topic in which may or may not be the version you're using. We're keeping this tutorial online as a courtesy to users of , but we consider it archived.

Alternate resources

Sprout Video

When it comes to rendering a page, the application compares the URL against the routes until one matches, Symfony reads the _controller key and executes that function. The page you want to render is built in the function. Controller functions are dead-simple, and there’s just one big rule: it must return a Symfony Response object. In this lesson, we'll build our Response, take a look at JSON, and then render the template using the Symfony templating service.