Notice: You are browsing the documentation for PrestaShop 9,
which is currently in development.
You might want to read the documentation for the current version, PrestaShop 8.
Read the current version of this page
Controller and Routing
Controllers are responsible for performing “Actions”. Actions are methods of Controllers which mapped to a route, and that return a Response
.
Migration tips
- If you consider that a legacy Controller needs to be split into multiple controllers (for example: different URLs), it’s the right time to do it.
- Controllers are not available for override and can be regarded as internal classes, therefore we don’t consider changing Controller’s namespace as a backward-compatibility break.
- Symfony controllers should be thin and have only one responsibility: getting the HTTP Request from the client and returning an HTTP Response. This means that all business logic should be placed in dedicated classes outside the Controller.
- Never, ever call the legacy controller inside the new controller. It’s a no go, no matter the reason!
- Try to avoid creating helper methods in your controller. If you find yourself needing them, that might mean the Controller is becoming too complex. This can be solved by extracting the code into dedicated services.