Phraseanet has a plugin system since version 3.8. It allows services customization (log, autnetication) and views (customized home pages).
A Phraseanet plugin is a directory containng a manifest.json file that describes the plugin, a composer.json file that resolves its dependencies and a public directory that contains any public resources (icons, css, js, etc...).
Two commands allow to add and remove plugins :
Add a plugin:
bin/console plugin:add /path/to/plugin
Remove a plugin:
bin/console plugin:remove plugin-name
Plugin authoring is easy ; here is the minimal structure:
├── composer.json ├── manifest.json └── public
manifest.json is a declarative file for Phraseanet in a JSON format. Here is the minimal manifest.json file:
{
"name": "null-plugin",
"description" : "A plugin that does nothing."
}
Some properties can be added to the JSON document as follow:
{
"name": "custom-connector",
"description" : "A custom class connector",
"keywords" : ["connector"],
"authors" : [
{
"name" : "Author name",
"homepage" : "http://example.com",
"email" : "email@example.com"
}
],
"homepage" : "http://example.com/project/example",
"license" : "MIT",
"version" : "0.1",
"minimum-phraseanet-version": "3.8",
"maximum-phraseanet-version": "3.9",
"twig-paths": ["custom-twig-views"],
"services" : [
{
"class": "Vendor\\PluginService"
}
],
"commands" : [
{
"class": "Vendor\\CustomCommand"
}
],
"extra" : {
"custom-property" : "value"
}
}
Properties details for manifest.json:
Note
Twig is automatically configured for plugins: If a “views” directory exists in the plugin root directory, then a “plugins-%nom-du-plugin%” namespace is created in Twig.
composer.json file is used to solve plugin PHP dependencies and create a dedicated autoloader.
{
"name": "vendor/phraseanet-plugin-name",
"description": "A test plugin",
"license" : "MIT",
"autoload": {
"psr-0": {
"Vendor" : "src"
}
}
}
The file above declares that the plugin sources will be automatically loaded from the src directory and will follow a PSR-0 structure. It is recommended to read composer documentation for more information.
Lots of customizations are available with plugins, most of them require a strong knowledge in Silex, Twig and other components used by Phraseanet.
Reading plugins source code like Mail log plugin and Syslog plugin might give some advices for developement.
Two things should be noted:
Services registered with the “services” property of manifest.json file must implement Alchemy\Phrasea\Plugin\PluginProviderInterface interface.
Commands registered with the “commands” property of manifest.json file must implement Alchemy\Phrasea\Command\CommandInterface interface. The simplest way to do so is to extend the Alchemy\Phrasea\Command\Command abstract class.