power-modules/framework 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

power-modules/framework

最新稳定版本:v2.2.0

Composer 安装命令:

composer require power-modules/framework

包简介

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

README 文档

README

CI Packagist Version PHP Version License: MIT PHPStan

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?

  • 🔒 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

This framework is not just another option; it introduces a new architectural paradigm to the PHP ecosystem. It is built on a foundation of runtime-enforced encapsulation and true modularity, inspired by the principles of 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.

Quick Start

composer require power-modules/framework
use Modular\Framework\App\ModularAppBuilder;

$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);

⚡ PowerModuleSetup Extension System

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

$app = new ModularAppBuilder(__DIR__)
    ->withModules(UserModule::class, OrderModule::class)
    ->addPowerModuleSetup(new RoutingSetup())    // Adds HTTP routing to modules implementing HasRoutes interface
    ->addPowerModuleSetup(new EventBusSetup())   // Pulls module events and handlers into a central event bus
    ->build();

Available extensions:

Coming soon:

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

🚀 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 [
            UserService::class,
        ];
    }
}

class OrderModule implements PowerModule, ImportsComponents {
    public static function imports(): array {
        return [
            ImportItem::create(UserModule::class, UserService::class),
        ];
    }
}

Later: Independent microservices

class UserModule implements PowerModule, HasRoutes {
    public function getRoutes(): array
    {
        return [
            Route::get('/', UserController::class, 'list'),
        ];
    }

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

class OrderModule implements PowerModule, ImportsComponents {
    // Uses User HTTP API instead of direct service import
}

Your modules are designed with clear boundaries. When you're ready to scale, the module structure supports splitting them into separate services.

📚 Documentation

📖 Complete Documentation Hub - Comprehensive guides, examples, and API reference

Quick Links:

Contributing

See CONTRIBUTING.md for development setup and guidelines.

License

MIT License. See LICENSE for details.

统计信息

  • 总下载量: 79
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 11
  • 点击次数: 0
  • 依赖项目数: 6
  • 推荐数: 0

GitHub 信息

  • Stars: 10
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-09-19