This past week we saw an exciting new addition committed into Drupal 8 core. The addition of a plugin system. This plugin system is heavily inspired by the popular ctools module and its respective plugin piece. In this post I’d like to share what it is and how it is going to impact future Drupal development.
I had been following the discussion in the issue queues for a while now and spent some time trying to get my head around why exactly we needed plugins. My initial reaction, due to the fact that I have not had much exposure to the ctools plugin system, was why do we need plugins... aren’t modules serving this purpose? Well after further research, some head scratching, and some much needed code breaking it has become clear to me.
Modules have a very general use case. Looks at the big guys... Views... Panels... Tokens, they all serve a very general purpose and expose flexible interfaces to site builders to put some pretty amazing solutions together.
Plugins on the other hand serve a very specific use case. Some simple examples of a plugin could be a mathematical operation, a sorting algorithm, or an image style. These plugins can be used by modules to perform their assigned tasks. Modules can also implement plugins that extend the functionality of another module. In addition, site builders can then be exposed with an option as to which plugin to use within their implementation.
For example, say I have a module that sorts an inputted list of content using a sorting algorithm of the users choice. We will call this the “Sorter” module. Out of the browser the Sorter module only implements the “Selection Sort” but it implements this as a plugin. This means other modules could implement their own sorting algorithms that plug right into “Sorter”. As a result “Sorter” could display a drop down of all available sorting algorithms in the system allowing the user to pick what they require. The “Sorter” module does not need to know about what modules are contributing implementations due to that fact that the plugin system enforces a consistent interface for discovery.
I believe this system is going to have a profound impact on the way our modules can be extended and wired together. It will also most likely play a major role in making some core features like caching methods more extensible.
The future is full of excitement!

