PHPackages                             droath/plugin-manager - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. droath/plugin-manager

ActiveLibrary

droath/plugin-manager
=====================

A lightweight PHP package for defining, discovering and instantiating pluggable services.

1.0.4(7mo ago)01.1kMITPHP

Since Nov 3Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/droath/plugin-manager)[ Packagist](https://packagist.org/packages/droath/plugin-manager)[ RSS](/packages/droath-plugin-manager/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (6)Used By (0)

Plugin Manager
==============

[](#plugin-manager)

A lightweight PHP toolkit for discovering, describing, and instantiating pluggable services. It couples attribute-based metadata with a flexible discovery pipeline so you can publish extensions without wiring every class manually.

Features
--------

[](#features)

- Attribute-first definitions: describe plugins with `#[PluginMetadata]` directly on the class.
- Namespace discovery: scan one or more namespaces for implementations that match your interface contract.
- Extensible managers: override the constructor of `DefaultPluginManager` to inject discovery and container wiring.
- Container integration: opt into PSR-11 containers for dependency-rich plugins.
- Testing utilities: reference stubbed discovery helpers to keep specs fast and focused.

Installation
------------

[](#installation)

```
composer require droath/plugin-manager
```

The library targets PHP 8.1+ and expects Composer’s autoloader at runtime.

Core Concepts
-------------

[](#core-concepts)

- **Plugin metadata attribute**: `Droath\PluginManager\Attributes\PluginMetadata` marks eligible classes and captures identity fields such as `id` and `label`.
- **Plugin contracts**: every plugin must implement `Droath\PluginManager\Contracts\PluginInterface`. The `Plugin\PluginBase` abstract class ships with sensible defaults.
- **Discovery**: `Discovery\NamespacePluginDiscovery` scans configured namespaces for attributed classes that implement one or more target interfaces.
- **Plugin manager**: `DefaultPluginManager` expects a discovery implementation via its constructor. Extend it and override `__construct()` to provide the discovery strategy (and optionally register a container).
- **Container awareness**: when a plugin implements `PluginContainerInjectionInterface` the manager must satisfy `PluginManagerContainerAwareInterface` (see `Concerns\ContainerAware`).

Quick Start
-----------

[](#quick-start)

### 1. Declare a plugin

[](#1-declare-a-plugin)

```
