PHPackages                             glugox/module-generator - 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. glugox/module-generator

ActiveLibrary[Framework](/categories/framework)

glugox/module-generator
=======================

Tracks file changes, additions, and deletions for Laravel

v1.0.0(6mo ago)03[1 PRs](https://github.com/glugox/module-generator/pulls)MITPHPPHP &gt;=8.2

Since Oct 24Pushed 6mo agoCompare

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

READMEChangelogDependencies (14)Versions (7)Used By (0)

Glugox Module Generator
=======================

[](#glugox-module-generator)

A module-first scaffolding engine for Laravel applications designed to power the upcoming Magic orchestrator. The package consumes a module specification and materialises the backend and frontend building blocks that Magic expects, keeping everything organised inside versioned modules. Think of it as the module analogue of [`glugox/magic`](https://github.com/glugox/magic): you describe the capabilities, entities, and UI actions that a module should expose, and the generator wires up the Laravel side for you.

What the generator does today
-----------------------------

[](#what-the-generator-does-today)

- **Validates module specifications** before any files are written, including module metadata, entity schemas, relations, filters, and actions.
- **Maps specs into rich DTOs** that higher-level orchestration code (or tests) can reason about without touching raw arrays.
- **Creates module scaffolding** under `modules//` including:
    - `composer.json` preconfigured for PSR-4 autoloading and Laravel service discovery.
    - `.manufacture-manifest.json` that the Magic orchestrator can ingest.
    - `src/Providers/ModuleServiceProvider.php` ready for custom bindings and bootstrapping.
- **Supports stub-driven output**, making it simple to tailor the generated files to your organisation’s conventions.

Future iterations will expand the writer pipeline to create Laravel UI, HTTP, database, and front-end artefacts so modules feel as complete as Magic’s runtime expects.

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel (tested against the versions supported by `orchestra/testbench`)

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

[](#installation)

Require the package via Composer inside your Laravel project:

```
composer require glugox/module-generator
```

Publish the configuration to tweak paths, namespaces, and validation rules:

```
php artisan vendor:publish --provider="Glugox\ModuleGenerator\ModuleGeneratorServiceProvider" --tag=config
```

This will publish `config/module-generator.php` with sensible defaults for where modules live, their base namespace, and the stub directory.

Configuration reference
-----------------------

[](#configuration-reference)

Key options exposed in `config/module-generator.php`:

OptionDescription`module_path`Root directory where generated modules are written (defaults to `base_path('modules')`).`namespace`Default base namespace for generated modules.`stubs_path`Directory containing the stub templates used by writers.`spec.rules`Array of validation rules merged into the built-in schema rules.You can override these values per environment or publish your own stub files to align with your team’s standards.

Crafting a module specification
-------------------------------

[](#crafting-a-module-specification)

The generator expects a structured array (or JSON document) describing the module. At a minimum you provide the schema version and module metadata; entities, relations, filters, and actions are optional but unlock richer scaffolding.

```
{
  "schemaVersion": "1.0.0",
  "module": {
    "id": "glugox/module-billing",
    "name": "Billing",
    "namespace": "Glugox\\\\Billing",
    "description": "Invoices and payments",
    "capabilities": ["http:web", "http:api"]
  },
  "entities": [
    {
      "name": "Invoice",
      "fields": [
        { "name": "id", "type": "uuid", "hidden": true, "unique": true },
        { "name": "status", "type": "string", "searchable": true, "default": "draft", "options": ["draft", "paid", "void"] },
        { "name": "total", "type": "decimal", "nullable": false }
      ],
      "relations": [
        { "type": "belongsTo", "relatedEntityName": "Customer", "nullable": false },
        { "type": "hasMany", "relatedEntityName": "Payment", "cascade": true, "pivot": "invoice_payment" }
      ],
      "filters": [
        { "field": "status", "type": "select", "label": "Invoice Status", "options": ["draft", "paid", "void"] }
      ],
      "actions": [
        { "name": "markPaid", "type": "update", "field": "status" }
      ]
    }
  ]
}
```

### Fields, relations, filters, and actions

[](#fields-relations-filters-and-actions)

The DTO layer documents the shape of each component:

- **Fields** support flags for `searchable`, `unique`, `hidden`, `nullable`, an optional default value, and enumerated `options`.
- **Relations** describe how entities connect (e.g. `belongsTo`, `hasMany`), optionally specifying pivot tables, cascade behaviour, and nullability.
- **Filters** inform the orchestrator which UI filters to expose, including their type, label, and allowed options.
- **Actions** declare user-triggerable behaviours tied to a field or entity.

The validator enforces required keys and types, but you can extend or relax the schema by merging additional `spec.rules` in configuration.

Generating a module
-------------------

[](#generating-a-module)

You can feed the specification to the facade, a service container binding, or directly to `ModuleGeneratorManager`:

```
use Glugox\ModuleGenerator\Facades\ModuleGenerator;

$spec = json_decode(file_get_contents(base_path('specs/billing.json')), true);

ModuleGenerator::generate($spec);
```

This command will create a module directory under the configured `module_path` and populate it using the active writers. Each writer reads a stub, performs token replacement, and writes the finished file to disk.

The `.manufacture-manifest.json` file captures the canonical module metadata that Magic’s orchestrator will ingest to compose backend and frontend experiences. The generated service provider is ready for you to register bindings, routes, Livewire components, or Inertia pages that complete the module’s surface area.

Customising writers and stubs
-----------------------------

[](#customising-writers-and-stubs)

Writers are simple classes implementing `WriterInterface`. You can swap or extend them by passing a custom writer list when instantiating `ModuleGeneratorManager`, or by resolving the binding from the service container and decorating it. Each writer points to a stub file under the configured stub directory, so copying and editing those stubs lets you tailor the generated output without touching PHP code.

Future releases will ship additional writers for controllers, models, form requests, Vue/React components, and anything else Magic needs to assemble a full-stack module.

Testing &amp; development
-------------------------

[](#testing--development)

Run the full quality suite locally with Pest, PHPStan, Pint, and Rector:

```
composer test
```

During package development you can also run targeted commands:

- `composer test:unit` – run unit tests with coverage.
- `composer lint` – format code with Pint and analyse types with PHPStan.
- `composer build` – refresh the Testbench workbench app.

These scripts align with the package skeleton provided by `orchestra/testbench` and keep the generator production-ready.

Roadmap
-------

[](#roadmap)

- Expand the manifest schema to include UI layout, menu placement, and permissions.
- Generate Laravel backend artefacts (models, migrations, policies, controllers) and matching front-end components to mirror Magic’s runtime modules.
- Provide a CLI/Artisan wrapper so operators can scaffold modules directly from spec files stored in your Magic orchestrator.

Stay tuned as the project grows alongside the orchestrator—contributions and ideas are welcome!

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance66

Regular maintenance activity

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

206d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c2b7e809a0e1bbbe61a4be95d32ca463fdbb5ec6c7cab0541d5a23436da3f8c9?d=identicon)[glugox](/maintainers/glugox)

---

Top Contributors

[![glugox](https://avatars.githubusercontent.com/u/13313019?v=4)](https://github.com/glugox "glugox (9 commits)")

---

Tags

frameworklaravelfilechangesdeltaadditionsglugoxdeletions

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/glugox-module-generator/health.svg)

```
[![Health](https://phpackages.com/badges/glugox-module-generator/health.svg)](https://phpackages.com/packages/glugox-module-generator)
```

###  Alternatives

[hemp/presenter

Easy Model Presenters in Laravel

247592.6k1](/packages/hemp-presenter)[rahulalam31/laravel-abuse-ip

Block ip address of all spammer's around the world.

27431.5k](/packages/rahulalam31-laravel-abuse-ip)

PHPackages © 2026

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