Get started with Symfony 6 for beginners — Part 2 | Route, Controller, Rendering.

Azay Karimli
3 min readMay 9, 2022

In the last article, we have been successfully launched the Symfony application for the first time. In this part, we will take a look at the MCV concept and create our first Controller, Route, and view file with just one line.

What is MVC?

MVC (Model View Controller) is an architectural pattern that separates applications into 3 main logical components.

  • Model: corresponds to all the data-related logic that the user works with. Retrieving data, the crud operations are done in the Model object.
  • View: is responsible for the UI logic of the application.
  • Controller: Act as an interface between Model and View components to process all the business logic and incoming requests, manipulate data using the Model component and interact with the Views to render the final output.

First Controller

Let's create a Controller route to the specified address and will render the view page. We will use the Symfony CLI tool to create our first-ever controller. As always open the command prompt and go to the (cd: change directory) folder the Symfony project lives, in this tutorial it is the my_project folder, and type the line below:

$ symfony console make:controller FirstController

FirstController is the name of the controller. For more information click here.

--

--