Back to course

Creating your first Controller

Symfony 0 to Hero: The Complete 2026 Guide

The Controller

The Controller's job is to receive a Request and return a Response.

Use the maker bundle to generate one: bash php bin/console make:controller MainController

This generates src/Controller/MainController.php. Explore the code and try changing the return string.