Makes API Platform send its own events

Installs: 1 754

Dependents: 0

Suggesters: 0

Security: 0

Stars: 15

Watchers: 1

Forks: 4

Open Issues: 0


v0.1.0 2019-10-27 16:12 UTC

This package is auto-updated.

Last update: 2021-07-29 02:03:02 UTC


Coverage Status GitHub Actions

Makes API Platform send its own events.

It supports only GraphQL (for now).

Please support the Stages RFC if you want a support for REST.

This bundle is useful if you really want to use events. The recommended way to add your logic is to decorate the stages.

With this bundle, the following events will be dispatched during a query or a mutation executed by API Platform:

Event Query Mutation
PreReadEvent sent ✔️️ sent ✔️
PostReadEvent sent ✔️ sent ✔️
PreDeserializeEvent not sent ❌ sent ✔️
PostDeserializeEvent not sent ❌ sent ✔️
PreValidateEvent not sent ❌ sent ✔️
PostValidateEvent not sent ❌ sent ✔️
PreWriteEvent not sent ❌ sent ✔️
PostWriteEvent not sent ❌ sent ✔️
PreSerializeEvent sent ✔️ sent ✔️
PostSerializeEvent sent ✔️ sent ✔️

By using Event Listeners, you can add your custom logic where you need.

In an event sent by this bundle, you have access to:

  • the related resource,
  • the operation name (get, delete, etc.),
  • the related data (if it makes sense),
  • the context (an array with some useful data).


Make sure Composer is installed globally, as explained in the installation chapter of the Composer documentation.

Applications that use Symfony Flex

Open a command console, enter your project directory and execute:

$ composer require alanpoulain/api-platform-events-bundle

Applications that don't use Symfony Flex

Step 1: Download the Bundle

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

$ composer require alanpoulain/api-platform-events-bundle

Step 2: Enable the Bundle

Then, enable the bundle by adding it to the list of registered bundles in the config/bundles.php file of your project:

// config/bundles.php

return [
    // ...
    ApiPlatform\EventsBundle\ApiPlatformEventsBundle::class => ['all' => true],


For an explanation of how it works, please read the documentation.


This package is available under the MIT license.