Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Hart KT:
Custom Events in Symfony2 Bundle
Oct 12, 2015 @ 16:10:58

Hari KT has a quick tutorial posted to his site showing you how to use custom events in Symfony bundles from start to finish.

In this tutorial we will create a custom event for symfony2 bundle. Assuming you have downloaded the symfony-standard distribution to play.

He starts by creating a simple bundle (HktEventBundle) and building out the matching event class, extending the base Symfony EventDispatcherEvent. He then shows how to dispatch a simple event from a controller, triggering a html.event.page_viewed event when the request is made to this default controller. He matches this with a listener that subscribes to the event (including a handler method) and the changes you'll need to make to your configuration to wire them all together.

tagged: symfony2 bundle custom event simple tutorial introduction

Link: http://harikt.com/blog/2015/10/11/custom-events-in-symfony2-bundle/


Trending Topics: