Hii there,
We are trying to create a CMS and have decided to have only the core in the main project and other functionality in plugins.
We are now working on a blog plugin.
This blog plugin will add some routes, controllers and models (along with some other stuff).
However, we want to not have to configure pretty much anything on a per-install basis.
what I mean with that is that I don’t want to have to edit the composer.json
file to autoload it with psr-4
or do anything else.
What we want to have is that when we drop plugins in the plugin folder (plugins/Kikioboeru/blog
for example), it’ll automatically load everything in that plugin.
While reading the documentation, I came accross the Plugin::load()
function but I couldn’t really connect the dots here.
basically what we want is this (in rough terms):
if the plugin exists at plugins/Kikioboeru/plugin-name
, then load it (along with routes, models, controllers etc.), else, ignore it.
the specific things we want to load also should be configurable on a per-plugin basis (because not all plugins will have routes or models, for example).
My best guess was to just check whether plugins/Kikioboeru/plugin-name/src/Plugin.php
exists and load the plugin.
so something like:
if(file_exists("plugins/Kikioboeru/blog/Plugin.php")){
Plugin::load("blog");
}
But I wondered if there is a cleaner way on doing this.
I know I should use psr-4, but we want to keep the project as modular as possible without having to toy with the psr-4 autoloader all the time if we get a request for a new site.
We want to make it as “plug&play” as we possibly can without making it horrible to maintain.