Symfony components are great. Don’t Reinvent The Wheel !

Hidouri Anis
HidouriAnis
1 min readOct 13, 2017

--

By embracing the “don’t reinvent the wheel” philosophy, Symfony itself makes heavy use of existing PHP open-source projects as part of the framework.Lots of Symfony components are used in other web applications and frameworks, such as Laravel, Silex, Drupal 8, Sylius, and other.
So do not hesitate to use the components of symfony in your php projects and take advantage of the power that symfony has offered us.

Example of using Event Dispatcher component

The EventDispatcher component allows you to adopt the observer pattern — events/listeners, events/observers (Magento and others), actions/hooks (WordPress), etc. They all follow the same basic pattern but have different implementations.

Example : Magento2

If you take a look at magento2 vendors, you can see
vendor/symfony/event-dispatcher.

A simple use of symfony component look like this:

use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\Event;

$dispatcher = new EventDispatcher();

$dispatcher->addListener('event_name', function (Event $event) {
// ...
});

$dispatcher->dispatch('event_name');

--

--