PHPackages                             power-modules/framework - 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. [Framework](/categories/framework)
4. /
5. power-modules/framework

ActiveLibrary[Framework](/categories/framework)

power-modules/framework
=======================

Framework for building modular PHP applications and plugin ecosystems with encapsulated modules and PowerModuleSetup extensions

v2.2.2(4mo ago)12164↓78.1%16MITPHPPHP ^8.4CI passing

Since Sep 20Pushed 1mo agoCompare

[ Source](https://github.com/power-modules/framework)[ Packagist](https://packagist.org/packages/power-modules/framework)[ RSS](/packages/power-modules-framework/feed)WikiDiscussions main Synced today

READMEChangelog (10)Dependencies (10)Versions (12)Used By (6)

Modular Framework
=================

[](#modular-framework)

[![CI](https://github.com/power-modules/framework/actions/workflows/php.yml/badge.svg)](https://github.com/power-modules/framework/actions/workflows/php.yml)[![Packagist Version](https://camo.githubusercontent.com/46d08d08c4d3ffb497c1fe0078bda7622de17dd1d1ed2deac8a602df308bb4c3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f706f7765722d6d6f64756c65732f6672616d65776f726b)](https://packagist.org/packages/power-modules/framework)[![PHP Version](https://camo.githubusercontent.com/4b6fadb36548a4c454b4020f82ddb6b7e0e8f7fcbc58843e3fac347bc447fc88/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f706f7765722d6d6f64756c65732f6672616d65776f726b)](https://packagist.org/packages/power-modules/framework)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](LICENSE)[![PHPStan](https://camo.githubusercontent.com/1b02b2f6c2946c9b9ad2e14b1c79c5932fdcef4ea31b4d6e79d54af7d7e7a2a7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c253230382d626c7565)](#)

A **general-purpose modular architecture framework** for PHP. Build applications where each module has its own dependency injection container, with carefully controlled sharing through explicit import/export contracts.

> **💡 Versatile:** Works well for CLI tools, data pipelines, background processors, APIs, and complex PHP applications that benefit from clear module boundaries.

✨ Why Modular Framework?
------------------------

[](#-why-modular-framework)

- **🔒 True Encapsulation**: Each module has its own isolated DI container
- **⚡ PowerModuleSetup**: Extend module functionality without breaking encapsulation
- **🚀 Microservice Ready**: Isolated modules can easily become independent services
- **📋 Explicit Dependencies**: Import/export contracts make relationships visible
- **🧪 Better Testing**: Test modules in isolation with their own containers
- **👥 Team Scalability**: Different teams can own different modules
- **🔌 Plugin-Ready**: Third-party modules extend functionality safely

🚀 Architectural Vision
----------------------

[](#-architectural-vision)

This framework is more than just another library — it introduces a new architectural paradigm to the PHP ecosystem, built on **runtime-enforced encapsulation** and **true modularity**, inspired by mature systems like OSGi.

To understand the core innovations and how this framework differs from established solutions like Symfony and Laravel, please read our **[Architectural Vision Document](ARCHITECTURAL_VISION.md)**.

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

[](#quick-start)

```
composer require power-modules/framework
```

```
use Modular\Framework\App\ModularAppBuilder;

class OrdersModule implements PowerModule, ExportsComponents {
    public static function exports(): array {
        return [
            OrderService::class,
        ];
    }

    public function register(ConfigurableContainerInterface $container): void
    {
        $container->set(OrderRepository::class, OrderRepository::class)
            ->addArguments([DatabaseConnection::class]);
        $container->set(OrderService::class, OrderService::class)
            ->addArguments([OrderRepository::class]);
    }
}

$app = new ModularAppBuilder(__DIR__)
    ->withModules(
        \MyApp\Auth\AuthModule::class,
        \MyApp\Orders\OrdersModule::class,
    )
    ->build();

// Get any exported service
$orderService = $app->get(\MyApp\Orders\OrderService::class);
// Fully initialized, with all dependencies resolved within the module's own container
```

⚡ PowerModuleSetup Extension System
-----------------------------------

[](#-powermodulesetup-extension-system)

The framework's most powerful feature - **PowerModuleSetup** allows extending module functionality without breaking encapsulation:

```
$app = new ModularAppBuilder(__DIR__)
    ->withPowerSetup(...RoutingSetup::withDefaults())
    ->withModules(
        RoutingModule::class,
        RouterModule::class,
        UserModule::class,
        OrderModule::class,
    )
    ->withPowerSetup(new EventBusSetup()) // Pulls module events and handlers into a central event bus
    ->build();
```

**Available extensions:**

- [**power-modules/router**](https://github.com/power-modules/router) - HTTP routing with PSR-15 middleware and RFC 7807 problem-details defaults
- [**power-modules/plugin**](https://github.com/power-modules/plugin) - Plugin architecture for third-party modules
- [**power-modules/dependency-graph**](https://github.com/power-modules/dependency-graph) - Visualize module dependencies
- [**power-modules/dependency-graph-mermaid**](https://github.com/power-modules/dependency-graph-mermaid) - Mermaid plugin for dependency graph rendering
- [**power-modules/console**](https://github.com/power-modules/console) - PowerModuleSetup extension that auto-discovers and registers Symfony Console commands from Power Modules

Coming soon:

- **power-modules/events** - Event-driven architecture
- **Your own!** - Create custom PowerModuleSetup implementations for your needs

🚀 Microservice Evolution Path
-----------------------------

[](#-microservice-evolution-path)

Start with a modular monolith, evolve to microservices naturally:

*Today: Modular monolith*

```
class UserModule implements PowerModule, ExportsComponents {
    public static function exports(): array {
        return [
            // Expose the service directly for in-process use
            UserRepositoryInterface::class,
        ];
    }

    public function register(ConfigurableContainerInterface $container): void
    {
        $container->set(UserRepositoryInterface::class, UserService::class);
    }
}

class OrderModule implements PowerModule, ImportsComponents {
    public static function imports(): array {
        return [
            // Import the interface from UserModule for in-process communication
            ImportItem::create(UserModule::class, UserRepositoryInterface::class),
        ];
    }

    public function register(ConfigurableContainerInterface $container): void
    {
        $container->set(OrderService::class, OrderService::class)
            ->addArguments([UserRepositoryInterface::class]);
    }
}
```

*Later: Independent microservices*

```
class UserModule implements PowerModule, ExportsComponents, HasRoutes {
    public static function exports(): array {
        return [
            // Still export the same interface — now resolved to an HTTP client rather than an in-process service
            UserRepositoryInterface::class,
        ];
    }

    public function getRoutes(): array
    {
        return [
            // Define HTTP routes for the User API
            Route::get('/', UserController::class),
        ];
    }

    public function register(ConfigurableContainerInterface $container): void
    {
        // Implementation details remain private; OrderModule doesn't need to know anything changed
        $container->set(UserApiService::class, UserApiService::class)
            ->addArguments([Psr\Http\ClientInterface::class]);
        // Bind the interface to the API service instead of the in-process service
        $container->set(UserRepositoryInterface::class, UserApiService::class);

        $container->set(UserService::class, UserService::class);
        $container->set(UserController::class, UserController::class)
            ->addArguments([UserService::class]);
    }
}

class OrderModule implements PowerModule, ImportsComponents {
    public static function imports(): array {
        return [
            // The same import as before — now backed by an HTTP client instead of an in-process service.
            // You can also drop this import and implement your own HTTP client directly in OrderModule.
            ImportItem::create(UserModule::class, UserRepositoryInterface::class),
        ];
    }

    public function register(ConfigurableContainerInterface $container): void
    {
        $container->set(OrderService::class, OrderService::class)
            ->addArguments([UserRepositoryInterface::class]);
    }
}
```

> **ℹ️ Note:** This example is a simplified illustration of the evolution path. In a real application, `UserModule` might continue to support in-process communication alongside the HTTP client, and the actual microservice implementation would likely live in its own repository.

Because modules are designed with clear boundaries from the start, splitting them into independent services is a natural next step when you're ready to scale.

📚 Documentation
---------------

[](#-documentation)

**📖 [Complete Documentation Hub](docs/README.md)** - Comprehensive guides, examples, and API reference

**Quick Links:**

- [Getting Started](docs/getting-started.md) - Build your first module in 5 minutes
- [Use Cases](docs/use-cases/README.md) - Real-world examples (web APIs, ETL, etc.)
- [Architecture](docs/architecture.md) - Deep dive into framework internals

Contributing
------------

[](#contributing)

See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup and guidelines.

License
-------

[](#license)

MIT License. See [LICENSE](LICENSE) for details.

###  Health Score

48

—

FairBetter than 93% of packages

Maintenance86

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~16 days

Recently: every ~39 days

Total

11

Last Release

120d ago

Major Versions

v1.1.2 → v2.0.02025-09-25

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/12776808?v=4)[HomelessCoder](/maintainers/HomelessCoder)[@HomelessCoder](https://github.com/HomelessCoder)

---

Top Contributors

[![HomelessCoder](https://avatars.githubusercontent.com/u/12776808?v=4)](https://github.com/HomelessCoder "HomelessCoder (56 commits)")

---

Tags

frameworkdi containerdependency-injectionmodularecosystemmicroservicesmodular-architecturecomponent-basedplugin-systempower-modulesencapsulationpowermodulesetup

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/power-modules-framework/health.svg)

```
[![Health](https://phpackages.com/badges/power-modules-framework/health.svg)](https://phpackages.com/packages/power-modules-framework)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.8k543.8M20.1k](/packages/laravel-framework)[symfony/symfony

The Symfony PHP framework

31.4k87.2M2.2k](/packages/symfony-symfony)[cakephp/cakephp

The CakePHP framework

8.9k19.5M1.8k](/packages/cakephp-cakephp)[illuminate/contracts

The Illuminate Contracts package.

706130.3M13.3k](/packages/illuminate-contracts)[moonshine/moonshine

Laravel administration panel

1.3k253.1k81](/packages/moonshine-moonshine)[oro/platform

Business Application Platform (BAP)

645143.5k115](/packages/oro-platform)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
