{"id":18386242,"url":"https://github.com/bethropolis/plugin-system","last_synced_at":"2025-04-07T00:33:00.615Z","repository":{"id":180241495,"uuid":"664824625","full_name":"bethropolis/plugin-system","owner":"bethropolis","description":"This is a lightweight, flexible, hook and event based plugin manager and system for any php based project.","archived":false,"fork":false,"pushed_at":"2024-09-25T23:59:50.000Z","size":621,"stargazers_count":4,"open_issues_count":7,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-12T20:53:55.544Z","etag":null,"topics":["php","plugin-manager","plugin-system","plugins"],"latest_commit_sha":null,"homepage":"https://bethropolis.github.io/plugin-system/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bethropolis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-10T20:44:05.000Z","updated_at":"2024-09-25T23:58:57.000Z","dependencies_parsed_at":null,"dependency_job_id":"1327fce5-29fd-4e6e-945c-b4c437eb24e9","html_url":"https://github.com/bethropolis/plugin-system","commit_stats":null,"previous_names":["bethropolis/plugin-manager","bethropolis/plugin-system"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bethropolis%2Fplugin-system","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bethropolis%2Fplugin-system/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bethropolis%2Fplugin-system/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bethropolis%2Fplugin-system/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bethropolis","download_url":"https://codeload.github.com/bethropolis/plugin-system/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223267709,"owners_count":17116693,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["php","plugin-manager","plugin-system","plugins"],"created_at":"2024-11-06T01:21:08.331Z","updated_at":"2024-11-06T01:21:09.051Z","avatar_url":"https://github.com/bethropolis.png","language":"PHP","readme":"# A PHP Plugin System\n[![PHP test](https://github.com/bethropolis/plugin-system/actions/workflows/main.yml/badge.svg?event=push)](https://github.com/bethropolis/plugin-system/actions/workflows/main.yml) [![CodeFactor](https://www.codefactor.io/repository/github/bethropolis/plugin-system/badge)](https://www.codefactor.io/repository/github/bethropolis/plugin-system) [![Contributions](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/dopecodez/Wikipedia/issues) [![GitHub version](https://badge.fury.io/gh/bethropolis%2Fplugin-system.svg)](https://badge.fury.io/gh/bethropolis%2Fplugin-system)\n\n\nThis is a lightweight, flexible, hook and event based  plugin manager and system.\n\nIt allows you to easily integrate plugins feature into your PHP applications, providing a modular and extensible architecture.\n\n\n\n## Features\n\n- Easy integration\n- Dynamic loading\n- Hook-based architecture\n- Event-driven programming\n- Flexible and extensible\n- plugin manager included\n- plugin life cycle\n\n\n## Installation\n\nyou will require composer to install. Run the following command in your project directory:\n```php\ncomposer require bethropolis/plugin-system\n```\n\nyou can also download the latest release and add it to your project directory.\n\u003e note that if you do this you will have to require the autoloader file into your project scripts.\nexample\n```php\nrequire \"plugin-system/src/autoload.php\";\n```\n\n\n## Usage\n\n### Loading Plugins\nTo load plugins from a specific directory, use the `loadPlugins` method:\n\n\n```php\n\nrequire \"vendor/autoload.php\"; // for download installed method just replace this line with the autoloader.\n\nuse Bethropolis\\PluginSystem\\System;\n\n$dir = __DIR__ . \"/examples/\"; # directory to load plugins from\nSystem::loadPlugins($dir);\n\n```\n\n## Linking Plugins to Hooks\nPlugins functions can be linked to hooks using the `linkPluginToHook` method. This allows you to define actions that will be executed when a particular hook is triggered:\n```php\nuse Bethropolis\\PluginSystem\\System;\n\n// Link a plugin function to a hook\nSystem::linkPluginToHook('my_hook', $callback);\n```\n\n### Triggering Hooks and Events\nHooks can be triggered using the `executeHook()` method, and events can be triggered using the `triggerEvent()` method. Here's an example:\n\n```php\nuse Bethropolis\\PluginSystem\\System;\n\n// Trigger a hook\nSystem::executeHook('my_hook', $pluginName, ...$args);\n\n// trigger multiple hooks\nSystem::executeHooks(['my_hook1', 'my_hook2'], $pluginName, ...$args);\n\n# Events\n// Register an event\nSystem::registerEvent('my_event');\n\n// Add an action to the event\nSystem::addAction('my_event', function ($arg) {\n    // Action code here\n});\n\n// Trigger the event\nSystem::triggerEvent('my_event', ...$args);\n```\n\n## plugin\n\nhere is an example of a plugin:\n```php\n\n// eg. FILE: /plugins-folder/examplepugin.php\n\nclass ExamplePlugin extends \\Bethropolis\\PluginSystem\\Plugin\n{\n\n    public function initialize()\n    {\n        $this-\u003elinkHook('my_hook', array($this, 'myCallback'));\n    }\n\n\n\n    public function myCallback($name = [])\n    {\n        $name = array_shift($name);\n        return \"hello {$name}\";\n    }\n}\n```\n\n## more Examples\n\nThe [examples](examples/) directory contains sample plugins that demonstrate the usage of the Plugin System. \n\n## Contributing\n\nContributions to the project are welcome! If you encounter any issues, have suggestions for improvements, or would like to add new features, please feel free to open an issue or submit a pull request.\n\n\n## About\n\nthis project was made to be a plugin management system for another one of my [project](https://github.com/bethropolis/suplike-social-website) but I hope it can help someone else out there.\n\n## License\n\nthis project is released under the [MIT License](https://opensource.org/licenses/MIT). You can find more details in the [LICENSE](LICENSE) file.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbethropolis%2Fplugin-system","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbethropolis%2Fplugin-system","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbethropolis%2Fplugin-system/lists"}