whilesmart/laravel-plugin-engine
最新稳定版本:v1.0.0
Composer 安装命令:
composer require whilesmart/laravel-plugin-engine
包简介
Laravel plugin engine for WhileSmart applications
README 文档
README
A flexible and powerful plugin system for Laravel applications.
Features
- Plugin discovery and registration
- Enable/disable plugins
- Plugin dependencies
- Console commands for plugin management
- Event-driven architecture
- Easy to extend
Installation
- Install the package via Composer:
composer require whilesmart/laravel-plugin-engine
- Publish the configuration file (optional):
php artisan vendor:publish --provider="WhileSmart\LaravelPluginEngine\Providers\PluginServiceProvider" --tag=config
Configuration
Publish the configuration file:
php artisan vendor:publish --provider="WhileSmart\LaravelPluginEngine\Providers\PluginServiceProvider" --tag=config
Edit the config/plugins.php file to configure the plugin system:
return [ 'path' => base_path('plugins'), // Path where plugins are stored 'namespace' => 'Plugins', // Root namespace for plugins ];
Usage
Available Commands
plugin:list- List all available pluginsplugin:info {id}- Show information about a pluginplugin:enable {id}- Enable a pluginplugin:disable {id}- Disable a pluginplugin:install {package}- Install a pluginplugin:discover- Discover and register all available plugins
Creating a Plugin
- Create a new directory in the
pluginsdirectory (or your configured path) - Create a
plugin.jsonfile with the following structure:
{
"id": "example-plugin",
"name": "Example Plugin",
"description": "A sample plugin",
"version": "1.0.0",
"namespace": "Plugins\\Example",
"provider": "Plugins\\Example\\ExampleServiceProvider",
"enabled": true,
"requires": {
"php": ">=8.1",
"laravel/framework": "^10.0"
}
}
- Create a service provider for your plugin:
<?php namespace Plugins\Example; use Illuminate\Support\ServiceProvider; class ExampleServiceProvider extends ServiceProvider { public function register() { // Register bindings } public function boot() { // Boot logic $this->loadRoutesFrom(__DIR__.'/routes/web.php'); $this->loadViewsFrom(__DIR__.'/resources/views', 'example'); $this->loadMigrationsFrom(__DIR__.'/database/migrations'); } }
Plugin Structure
plugins/
example-plugin/
src/
Http/
Controllers/
Models/
Providers/
ExampleServiceProvider.php
resources/
views/
routes/
web.php
database/
migrations/
plugin.json
README.md
Events
The plugin system dispatches several events that you can listen for:
WhileSmart\PluginEngine\Events\PluginEnabling- Fired before a plugin is enabledWhileSmart\PluginEngine\Events\PluginEnabled- Fired after a plugin is enabledWhileSmart\PluginEngine\Events\PluginDisabling- Fired before a plugin is disabledWhileSmart\PluginEngine\Events\PluginDisabled- Fired after a plugin is disabledWhileSmart\PluginEngine\Events\PluginInstalled- Fired after a plugin is installedWhileSmart\PluginEngine\Events\PluginDiscovered- Fired when a plugin is discovered
License
This project is open-source and licensed under the MIT License.
统计信息
- 总下载量: 251
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: proprietary
- 更新时间: 2025-07-10