Plugin vs Component: what's the difference?

What is the difference between Phalcon\Mvc\User\Plugin and Phalcon\Mvc\User\Component?


Hi, I've seen this discussion

Phalcon\Mvc\User\Plugin is recommended being used in plugins and Phalcon\Mvc\User\Component in user components

Ok. But what is Plugin and what is Component?


A plugin is like the Security plugin in INVO (, it implements methods as events of some component, in this case Dispatcher (

A component is a class or group of classes that provide custom functionality to the application but aren't aware of events, like the Elements class:


That's the only difference? So Plugin is some kind of the events listener and Components is for for all other purposes (including user interface)?


Yep, a plugin is like a listener, however both classes don't have any real differences, they extend from Phalcon\DI\Injectable to easily access the service locator


Thanks! @boston perhaps it is necessary to say more about this in the docs


I concur with Agent-J, there is no documentation about the Component/Plugin

How about controllers? Are they act like plugin? (In some case, they concern with event like beforeExecute Route etc)

Controllers handles the application login in the MVC but again can be used as a plugin if registered in the services using the di component.

Just as it sounds. The way I understand plugins and components is that, component can be used independently but plugins (as they sound) have to be plugged in a component or module so to speak in order to execute. That's why plugins rely heavily to events (action from the user) on run time. Plugins can extend the functionability of a component by adding some behaviours. A good example can be; A car (component) can be driven when it is raining(event) without wipers(plugins). But with wipers the car can be driven much better due to behavior change in weather.

From this anology plugin can make a component fit in different usability while reducing the number of bugs.