-
Notifications
You must be signed in to change notification settings - Fork 1
getting plugin info
Bethuel edited this page Aug 29, 2023
·
1 revision
You may need plugins info maybe to display plugin information, configuration
to get plugin info you will need to have a multi-file plugin with a plugin.json file.
// index.php
require "vendor/autoload.php";
use Bethropolis\PluginSystem\System;
use Bethropolis\PluginSystem\Info;
$dir = __DIR__ . "/examples/";
System::loadPlugins($dir);
$info = new Info();
$info->refreshPlugins();
print_r(json_encode($info->getPlugins()));{
"addition": {
"name": "addition",
"version": "0.0.1",
"author": "Rafael Gomes",
"license": "MIT",
"description": "An addition plugin",
"files": [
{
"target": "..\/index.php",
"require": "\/plugin.php"
}
]
}
}The output will be an array of installed plugins in the plugins directory.
Plugins listed are the one's that have aplugin.jsonfile.
This method gets the class names of the installed plugins. It works on all plugins in the plugin directory.
// index.php
require "vendor/autoload.php";
use Bethropolis\PluginSystem\System;
$dir = __DIR__ . "/examples/";
System::loadPlugins($dir);
print_r(json_encode(System::getPlugins()));[
"Bethropolis\\PluginSystem\\additionPlugin\\Load",
"Bethropolis\\PluginSystem\\anotherPlugin\\Load",
"Bethropolis\\PluginSystem\\bethroPlugin\\Load",
"Bethropolis\\PluginSystem\\myPlugin\\Load",
"SingleFilePlugin"
]happy coding! 💜