承接 yohns/plugable 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

yohns/plugable

最新稳定版本:0.1.0

Composer 安装命令:

composer create-project yohns/plugable

包简介

Plugins, hooks and filters to add to your site to allow for injecting different functions at set times while your site is loading.

README 文档

README

<?php
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)) {
					include ($pluginDir . $k . '/' . $fi);
				} else {
					die($pluginDir . $k . '/' . $fi . ' file was not found');
				}
			}
		}
	}
	if ($v['Route'] != '') {
		$Routes[] = $v['Route'];
	}
}

统计信息

  • 总下载量: 8
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-08-18