定制 glugox/module 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

glugox/module

最新稳定版本:1.0.0

Composer 安装命令:

composer require glugox/module

包简介

Module abstractions that all modules use

README 文档

README

Introduction

The glugox/module package defines the foundation for modular development in Laravel. It introduces the common abstractions, contracts, and base classes that every module must use. This ensures consistency across all modules and makes it possible for tools like glugox/orchestrator and glugox/module-generator to integrate seamlessly.

Key Concepts

1. Module Abstraction

  • A module is a self-contained package that adds functionality to a Laravel app.
  • Every module must implement the ModuleContract or extend the abstract Module base class.
  • A module contains its own routes, migrations, views, assets, and service providers.

2. Module Manifest

  • The manifest describes the metadata of a module.
  • It includes: id, name, namespace, description, version, and capabilities.
  • It allows orchestrators to discover and load modules without knowing implementation details.

3. Contracts

Located in src/Contracts, they enforce module capabilities:

  • ModuleContract → defines required metadata methods.
  • HasRoutes, HasMigrations, HasViews, HasAssets → optional feature interfaces.
  • ManifestContract → for objects that expose manifest data.

4. Support Classes

  • ModuleManifest → value object holding module metadata.
  • ModuleLoader → utility to bootstrap and resolve modules.

5. Service Provider Integration

  • ModuleServiceProvider ensures that modules can register services into Laravel’s container and lifecycle.

Package Structure

glugox/module/
├── src/
│   ├── Contracts/
│   │   ├── ModuleContract.php
│   │   ├── ManifestContract.php
│   │   ├── HasRoutes.php
│   │   ├── HasViews.php
│   │   ├── HasMigrations.php
│   │   └── HasAssets.php
│   ├── Support/
│   │   ├── ModuleManifest.php
│   │   └── ModuleLoader.php
│   ├── Module.php
│   └── ModuleServiceProvider.php
└── composer.json

Example Implementation

Defining a Module

use Glugox\Module\Module;
use App\Providers\BillingServiceProvider;

class BillingModule extends Module
{
    public function id(): string { return 'company/billing'; }
    public function name(): string { return 'Billing'; }
    public function description(): string { return 'Invoices and payments'; }
    public function version(): string { return '1.0.0'; }
    public function capabilities(): array { return ['http:web', 'http:api']; }

    public function serviceProvider(): string
    {
        return BillingServiceProvider::class;
    }

    public function routesPath(): ?string
    {
        return __DIR__ . '/routes/web.php';
    }
}

Example Manifest

{
  "id": "company/billing",
  "name": "Billing",
  "namespace": "Company\\Billing",
  "description": "Invoices and payments",
  "version": "1.0.0",
  "capabilities": ["http:web", "http:api"]
}

How It Fits in the Ecosystem

  • glugox/module-generator creates modules that extend the Module base class.
  • glugox/orchestrator loads modules by reading their manifests and registering providers.
  • Main Laravel App → simply requires modules as composer packages and lets orchestrator manage them.

Benefits

  • Standardization → Every module follows the same pattern.
  • Reusability → Modules can be reused across multiple Laravel projects.
  • Separation of Concerns → Clear split between contracts (in glugox/module), orchestration (in glugox/orchestrator), and generation (in glugox/module-generator).

Next Steps

  • Finalize the ModuleContract and optional feature interfaces.
  • Improve ModuleLoader to handle different discovery strategies (filesystem, composer).
  • Document how modules interact with Laravel’s container and lifecycle in detail.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固