Your First Extension

As Contao itself is just a Symfony bundle that’s loaded to your Symfony application or Contao Managed Edition, writing your own bundle is very similar to writing a regular Symfony bundle. It’s thus very important you read the respective Symfony documentation first. You can also have a look at the Getting Started guide which covers the basics.

Copying the excellent documentation of Symfony itself into the Contao documentation doesn’t make much sense thus you’ll learn about the differences between a Symfony bundle and a Contao bundle.

The first and most obvious difference between a Symfony and a Contao bundle is its type in the composer.json:

-"type": "symfony-bundle",
+"type": "contao-bundle",

The one and only reason as of today is the simple fact that it allows us to distinguish Contao bundles from other Composer packages on packagist.org. It’s especially useful for the package index of the Contao Manager where it makes no sense to show any other packages to the end users.

Structure

We recommend you stick to the structure recommended by Symfony in their docs. One thing that will differ are the Contao specific resources that will go under contao/ (or src/Resources/contao/ if you are using the old bundle structure). Contao specific resources in general are the following folders:

  • config
  • dca
  • languages
  • templates

Although you might not need config and languages because most of what used to be configured in config/config.php has moved to the Symfony Container instead and you may also write your language files using the Symfony Translator.

Also make sure you check out the Contao Skeleton Bundle which may help you to get your foundation right.

Integration of the Manager Plugin

If you want to provide integration with the Contao Managed Edition make sure you checkout the documentation on the Contao Manager Plugin.