1. Go to this page and download the library: Download echo-fusion/pluginmanager library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
echo-fusion / pluginmanager example snippets
use EchoFusion\PluginManager\PluginManager;
use Psr\Container\ContainerInterface;
$createPluginManager = function(ContainerInterface $container) {
$plugins = [
MyPlugin::class,
AnotherPlugin::class,
];
return new PluginManager($container, $plugins);
}
// Usage
$container = // Your container implementation here
$pluginManager = $createPluginManager($container);
try {
// Register plugins for a specific environment (e.g., 'dev')
$pluginManager->register('dev');
} catch (PluginManagerException $e) {
// Handle any exceptions related to plugin management
echo 'Error registering plugins: ' . $e->getMessage();
} catch (Throwable $e) {
// General fallback for other types of exceptions
echo 'An unexpected error occurred: ' . $e->getMessage();
}
declare(strict_types=1);
namespace YourNamespace\Plugins;
use EchoFusion\PluginManager\PluginInterface;
use EchoFusion\PluginManager\Environment;
class ExamplePlugin implements PluginInterface
{
private $service;
public function register(): void
{
// Initialize the service
$this->service = $this->initializeService();
// Set up configurations
$this->configureSettings();
// Register event listeners
$this->registerEventListeners();
echo "ExamplePlugin has been registered successfully.\n";
}
public function getSupportedEnvironments(): array
{
return ['dev','prod'];
}
//...
}
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.