Namespaces & Class Names

Namespaces

The following is a list of recommended namespaces for various classes when developing within the Contao framework. None of these are mandatory though.

NamespaceResource
App\ContaoManagerContao Manager related classes (e.g. the Manager Plugin)
App\Controller\ContentElementContent element fragment controllers
App\Controller\FrontendModuleFront end module fragment controllres
App\CronCron jobs
App\EventListenerSymfony event listeners, Contao hooks & callbacks
App\ModelDatabase models
App\WidgetForm widgets

Class Names

As it is customary within the Symfony environment, classes of certain namespaces should also be named with a namespace specific suffix:

NamespaceSuffixExample
App\ControllerControllerApp\Controller\ExampleController
App\CronCronApp\Cron\ExampleCron
App\EventListenerListenerApp\EventListener\ExampleListener
App\ModelModelApp\Model\ExampleModel