MVC in OpenDXP
In terms of sending output to the frontend, OpenDXP follows the MVC pattern. Therefore it is crucial to know the fundamentals about the pattern in general and the specifics in combination with OpenDXP.
MVC is a software design pattern for web applications and separates the code into the following components:
- Model - defines basic functionality like data access routines, business, etc.
- View - defines what is presented to the user (the "template")
- Controller - Controllers bring all the patterns together, they manipulate models, decide which view to display, etc.
If you don't know the MVC pattern please read this article first.
The MVC module of OpenDXP is built on top of Symfony. If you are new to Symfony you can read about controllers in the Symfony manual. With this knowledge learning OpenDXP will be much easier and faster.
Basic file structure and naming conventions
The most common module for working within the MVC in your OpenDXP project is the App. So the most frequently
used folders and files concerning the MVC within the website module are the following:
| Path | Description | Example |
|---|---|---|
/src/Controller | The controllers directory | eg. ContentController.php |
/templates/ | The view (template) directory, the naming (sub folders and file names) follows also the naming-convention of Symfony (/templates/[controller]/[action].html.twig) |
All OpenDXP plugins and other modules follow the same pattern.
The following sub chapters provide insight into details of the OpenDXP MVC structure and explain the topics