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.
- A module is a self-contained package that adds functionality to a Laravel app.
- Every module must implement the
ModuleContractor extend the abstractModulebase class. - A module contains its own routes, migrations, views, assets, and service providers.
- The manifest describes the metadata of a module.
- It includes:
id,name,namespace,description,version, andcapabilities. - It allows orchestrators to discover and load modules without knowing implementation details.
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.
ModuleManifest→ value object holding module metadata.ModuleLoader→ utility to bootstrap and resolve modules.
ModuleServiceProviderensures that modules can register services into Laravel’s container and lifecycle.
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
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';
}
}{
"id": "company/billing",
"name": "Billing",
"namespace": "Company\\Billing",
"description": "Invoices and payments",
"version": "1.0.0",
"capabilities": ["http:web", "http:api"]
}glugox/module-generatorcreates modules that extend theModulebase class.glugox/orchestratorloads modules by reading their manifests and registering providers.- Main Laravel App → simply requires modules as composer packages and lets orchestrator manage them.
- 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 (inglugox/orchestrator), and generation (inglugox/module-generator).
- Finalize the
ModuleContractand optional feature interfaces. - Improve
ModuleLoaderto handle different discovery strategies (filesystem, composer). - Document how modules interact with Laravel’s container and lifecycle in detail.