Loader Plugins - ThomasWeinert/FluentDOM GitHub Wiki
Loader Plugins
You can define you own loaders in separate Composer packages. Here are several reasons for this approach.
- Special formats that are not needed often.
- Dependencies to 3rd party libraries
- Separate updates and releases
The composer.json
of the plugin should require the FluentDOM package and add a file based autoloader.
{
"require": {
"fluentdom/fluentdom": "~5.2",
},
"autoload": {
"files" : ["src/plugin.php"]
}
}
The file based autoloader triggers the plugin registration.
namespace FluentDOM\HTML5 {
if (class_exists('\\FluentDOM')) {
\FluentDOM::registerLoader(
new \FluentDOM\Loader\Lazy(
[
'text/html5' => function () {
return new Loader;
},
'html5' => function () {
return new Loader;
}
]
)
);
}
}