wondercms icon indicating copy to clipboard operation
wondercms copied to clipboard

[Feature request] Dependency handling

Open StephanStanisic opened this issue 4 years ago • 1 comments

Currently a lot of themes and plugins have dependencies that are not required to run WonderCMS core. For example, a lot of themes I've created use php's DOMDocument. This mostly isn't a problem, since most shared hosts have this installed by default. But when one of these themes is installed, the whole site breaks and someone would need to go and delete the plugin/theme via ftp.

I would suggest some way to define dependencies from a theme or plugin. Either through a extra file, just like description and version, or by registering them through a php function.

I would also suggest the possibility to require plugins. This could make bundling dependencies that get used by multiple plugins easier, and less heavy on the disk. (e.g. a plugin that includes a icon font, and a theme could require this to be installed)

Example of a requirements file:

php:DOMDocument
php:mbstring
plugin:robiso/summernote-editor

These will be read when installing, and the plugin will fail to install when these requirements are not met. With the plugin requirements we could maybe install the required plugin and try again.

Or via the plugin.php or functions.php in a theme:

$Wcms->addRequirement("php", "DOMDocument");
$Wcms->addRequirement("php", "mbstring");
$Wcms->addRequirement("plugin", "robiso/summernote-editor");

This would be the first few lines of code in the file, and the plugin will stop loading if the requirements are not met.

My preference would go to the first option, since that would give people the option to delete a required plugin after installing if they know what they are doing. (When not using the icon font for example)

I think that this is a feature that has to be implemented into core, since a lot of plugins would require something like this. I'll take a look at what I can do with the core as a proof of concept.

StephanStanisic avatar Jul 28 '20 08:07 StephanStanisic

Perhaps this and other issues could be solved by using Composer? composer.json

{
    "require": {
        "ext-dom": "*",
        "ext-curl": "*",
        "ext-mbstring": "*"
    }
}

But I have no idea how much work that would be....

ghost avatar Mar 26 '23 19:03 ghost