krystal-sf/plugin-manager
Composer 安装命令:
composer require krystal-sf/plugin-manager
包简介
Symfony Advanced Plugins Manager
README 文档
README
A complete and production-ready plugin management system for Symfony applications.
Features
Core Plugin Management
- Plugin Discovery: Automatic discovery of plugins implementing
PluginBundleInterface - Activation/Deactivation: Full lifecycle management with validation pipeline
- Dependency Management: Declare dependencies between plugins with version constraints
- Status Tracking: Three plugin states (ACTIVE, INACTIVE, FORCED)
Advanced Features
- Validation Pipeline: Multi-validator system (PHPStan, Composer, Kernel, Dependencies)
- Event System: Pre/post activation and deactivation events with cancelation support
- Artifact Scanning: Automatic detection of routes, services, entities, migrations
- Composer Integration: Automatic symlink management and dependency installation
- CLI Commands: Complete command-line interface for plugin management
Routing & Services
- 3-Level Routing: Package → Bundle → Context organization
- Environment-Aware: Services and routes per environment (dev, prod, test)
- Multi-Context: Support for admin, api, public, secured contexts
- Multiple Formats: YAML, XML, PHP configuration files
Installation
composer require ksf/plugins-bundle Enable the Bundle
Add to config/bundles.php:
return [ // ... Ksf\Core\Plugins\KsfPluginsBundle::class => ['all' => true], ]; Configure
Create config/packages/ksf_plugins.yaml:
ksf_plugins: plugins_directory: '%kernel.project_dir%/plugins' validation: enabled: true phpstan: enabled: true level: 8 configuration: '%kernel.project_dir%/phpstan.neon' composer: enabled: true kernel: enabled: true Quick Start
1. Create a Plugin
<?php namespace App\Plugin\MyPlugin; use Ksf\Core\Plugins\Contract\AbstractPluginBundle; class MyPluginBundle extends AbstractPluginBundle { public function getCode(): string { return 'my_plugin'; } public function getEnvironments(): string|array { return 'all'; // or ['dev', 'prod'] } } 2. Discover & Activate
# Discover new plugins bin/console plugin:discover # List all plugins bin/console plugin:list # Activate a plugin bin/console plugin:activate my_plugin # Activate with dependencies bin/console plugin:activate my_plugin --with-dependencies 3. Manage Plugin Structure
plugins/my-plugin/ ├── src/ │ └── MyPluginBundle.php ├── config/ │ ├── routes/ │ │ ├── 1-packages/ │ │ │ └── my_plugin.yaml │ │ ├── 2-bundles/ │ │ │ └── my_plugin.yaml │ │ └── 3-contexts/ │ │ ├── admin/ │ │ │ └── my_plugin.yaml │ │ └── api/ │ │ └── my_plugin.yaml │ └── services/ │ ├── 1-packages/ │ │ └── my_plugin.yaml │ ├── 2-bundles/ │ │ └── my_plugin.yaml │ └── 3-contexts/ │ └── admin.yaml ├── migrations/ ├── src/Entity/ └── composer.json CLI Commands
| Command | Description |
|---|---|
plugin:list | List all plugins with status and filters |
plugin:activate <code> | Activate a plugin |
plugin:deactivate <code> | Deactivate a plugin |
plugin:discover | Discover new plugins |
plugin:info <code> | Display plugin information and artifacts |
plugin:dependencies <code> | Show plugin dependencies |
plugin:clean-duplicates | Clean duplicate plugin entries |
Documentation
Getting Started
Core Features
Advanced Topics
Key Concepts
Plugin States
| State | Description | Managed |
|---|---|---|
| ACTIVE | Enabled via Plugin Manager | ✅ Yes |
| INACTIVE | Installed but disabled | ✅ Yes |
| FORCED | Manually declared in bundles.php | ❌ No |
Dependency Management
Declare dependencies between plugins:
public function getDependencies(): array { return [ 'other_plugin' => '^1.0', // Semantic versioning 'base_plugin' => '~2.3', // Compatible with 2.3.x ]; } Features:
- ✅ Version constraint validation
- ✅ Circular dependency detection
- ✅ Topological sort for load order
- ✅ Cascade activation
- ✅ Deactivation prevention
Validation Pipeline
Multi-step validation before activation:
- PHPStan Validator: Static analysis at configured level
- Composer Validator: Dependency validation
- Kernel Validator: Symfony kernel boot test
- Dependency Validator: Plugin dependencies check
Each validator can report:
- ❌ ERROR: Blocks activation
- ⚠️ WARNING: Allows activation with warning
- ℹ️ INFO: Informational message
Event System
Listen to plugin lifecycle events:
use Ksf\Core\Plugins\Event\PluginActivatingEvent; use Symfony\Component\EventDispatcher\EventSubscriberInterface; class PluginListener implements EventSubscriberInterface { public static function getSubscribedEvents(): array { return [ PluginActivatingEvent::class => 'onPluginActivating', ]; } public function onPluginActivating(PluginActivatingEvent $event): void { // Cancel activation if needed if ($someCondition) { $event->stopPropagation(); } } } Available events:
PluginActivatingEvent- Before activation (cancelable)PluginActivatedEvent- After activationPluginDeactivatingEvent- Before deactivation (cancelable)PluginDeactivatedEvent- After deactivation
Requirements
- PHP 8.1 or higher
- Symfony 6.4 or 7.x
- Composer
Testing
# Run all tests vendor/bin/phpunit # Run specific test suite vendor/bin/phpunit --testsuite=Core vendor/bin/phpunit --testsuite=Functional # Run with coverage vendor/bin/phpunit --coverage-html coverage/ Contributing
- Follow BadPixxel coding standards (PSR-12 + PHPStan)
- Run quality checks before committing:
make quality - Write tests for new features
- Update documentation
License
This bundle is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
For the full copyright and license information, please view the LICENSE file that was distributed with this source code.
Support
- Issues: Report bugs on GitHub
- Documentation: See
/docsdirectory - Examples: See
docs/examples.md
Copyright (C) BadPixxel <www.badpixxel.com>
krystal-sf/plugin-manager 适用场景与选型建议
krystal-sf/plugin-manager 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 290 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「symfony」 「twig」 「components」 「krystal-sf」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 krystal-sf/plugin-manager 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 krystal-sf/plugin-manager 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 krystal-sf/plugin-manager 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Shoot aims to make providing data to your templates more manageable
This Symfony bundle integrates PhpSpreadsheet into Symfony using Twig.
A Twig extension to insert css as inline styles with a tag
Caching and compression for Twig assets (JavaScript and CSS).
The bundle for easy using json-rpc api on your project
Twig extensions for Tracy Debugger
统计信息
- 总下载量: 290
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 10
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-01-04