Attention
TYPO3 v11 has reached end-of-life as of October 31th 2024 and is no longer being maintained. Use the version switcher on the top left of this page to select documentation for a supported version of TYPO3.
Need more time before upgrading? You can purchase Extended Long Term Support (ELTS) for TYPO3 v11 here: TYPO3 ELTS.
AfterPackageActivationEvent
New in version 10.3
The event was introduced to replace the Signal/Slot
\TYPO3\
.
The PSR-14 event \TYPO3\
is triggered after a package has been activated.
Attention
This event is dispatched when an extension is activated in the Extension Manager, therefore starting with TYPO3 v11 this event is only dispatched in legacy installations, not in Composer-based installations. Use installer events by Composer for Composer-based installations.
Example
Registration of the event listener in the extension's Services.
:
services:
MyVendor\MyExtension\Package\EventListener\MyEventListener:
tags:
- name: event.listener
identifier: 'my-extension/extension-activated'
An implementation of the event listener:
<?php
namespace MyVendor\MyExtension\Package\EventListener;
use TYPO3\CMS\Core\Package\Event\AfterPackageActivationEvent;
final class MyEventListener
{
public function __invoke(AfterPackageActivationEvent $event)
{
if ($event->getPackageKey() === 'my_extension') {
$this->executeInstall();
}
}
private function executeInstall(): void
{
// do something
}
}