How to use and create plugins?
Existing Plugins#
Installation#
You can use as many plugins as you want.
-
Add the dependency with composer. Generally, the dependency can be found in the
composer.jsonfile in the theme repository. -
Register theme in the
config.ymlfile:#config.yml engine: extensions: - Carew\Plugin\Toc\TocExtension
That's it.
How to write a plugin#
The plugin must implements Carew\ExtensionInterface.
Carew will call ExtensionInterface::register and give itself
to the extension. So the plugin can alter everything.
The plugin can access to:
- The
carewinstance - The
container, an instance of pimple. - The
event_dispatcher, an instance of Symfony EventDispatcher.
You can have a look to the CoreExtension for more information.
Learn more about the carew architecture in the internal chapter.
You have created a plugin#
You have created a plugin and you want to share it? Write me an email and I will create a new repository on github/carew for you, or send me a pull request and add a new link.