1. Go to this page and download the library: Download yohns/plugable 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/ */
yohns / plugable example snippets
use Yohns\Core\Plugable;
// Define the plugin directory
$pluginDir = __DIR__.'/pluggable/plugins/';
// Define the plugins to load
$plugins = ['Events', 'News', 'Pictures'];
// Load the plugins with the directory variable
$loadedPlugins = Plugable::loadPlugins($plugins, $pluginDir);
echo "<pre>Loaded Plugins:\n";
print_r($loadedPlugins);
echo "</pre>";
// Add hooks
Plugable::addHook('startup', function() {
echo "Startup hook executed!<br>";
});
Plugable::addHook('shutdown', function() {
echo "Shutdown hook executed!<br>";
});
// Execute the 'startup' event hooks
Plugable::doHook('startup');
// Add a filter
Plugable::addFilter('content_filter', ['content' => 'Original content']);
// Execute the filter for 'content_filter'
$result = Plugable::doFilter('content_filter', function(array $data) {
// Modify the filtered data
$data[0]['content'] = 'Filtered content';
return $data;
});
echo "<pre>Filtered Data:\n";
print_r($result);
echo "</pre>";
// Execute the 'shutdown' event hooks
Plugable::doHook('shutdown');
//-- loading plugins
foreach ($loadedPlugins as $k => $v) {
if ($v['IncludeFiles'] != '') {
if (is_array($v['IncludeFiles'])) {
foreach ($v['IncludeFiles'] as $fi) {
if (is_file($pluginDir . $k . '/' . $fi)) {
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.