The exportTheme hook is triggered on whenever a theme gets exported via the back end. The hook enables you to add additional data to the XML as well as the ZIP archive. It passes the XML object, the ZIP archive object and the theme’s id as arguments and expects no return value.


  1. \DOMDocument $xml

    The XML object containing the theme’s data.

  2. \Contao\ZipWriter $zipArchive

    The ZIP archive object containing the theme’s files.

  3. int $themeId

    The ID of the theme.


// src/EventListener/ExportThemeListener.php
namespace App\EventListener;

use Contao\CoreBundle\DependencyInjection\Attribute\AsHook;
use Contao\ZipWriter;

class ExportThemeListener
    public function __invoke(\DOMDocument $xml, ZipWriter $zipArchive, int $themeId): void
        // Do something …