PHPackages                             glugox/magic - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. glugox/magic

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

glugox/magic
============

Tools for creating magic!

v1.0.4(8mo ago)1311[2 PRs](https://github.com/glugox/magic/pulls)MITPHPPHP ^8.4CI failing

Since Aug 26Pushed 8mo agoCompare

[ Source](https://github.com/glugox/magic)[ Packagist](https://packagist.org/packages/glugox/magic)[ Docs](https://github.com/glugox/magic)[ GitHub Sponsors](https://github.com/glugox)[ RSS](/packages/glugox-magic/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (17)Versions (27)Used By (0)

[![logo.svg](https://raw.githubusercontent.com/glugox/cloud/refs/heads/main/public/logo.svg)](https://raw.githubusercontent.com/glugox/cloud/refs/heads/main/public/logo.svg) Magic
===================================================================================================================================================================================

[](#-magic)

[![PHP Version](https://camo.githubusercontent.com/504ead6a583c68d8d62d7bfceed24e569ca613d7a36bed380281b3455b5c7b31/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e342d626c7565)](https://php.net)[![License](https://camo.githubusercontent.com/8bb50fd2278f18fc326bf71f6e88ca8f884f72f179d3e555e20ed30157190d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e737667)](LICENSE)[![Coverage](https://camo.githubusercontent.com/a556b1b137116e9d90938cce0a270c2dc43b90a0e82769d95c807ea229639d05/68747470733a2f2f636f6465636f762e696f2f67682f676c75676f782f6d616769632f6272616e63682f6d61696e2f67726170682f62616467652e737667)](https://camo.githubusercontent.com/a556b1b137116e9d90938cce0a270c2dc43b90a0e82769d95c807ea229639d05/68747470733a2f2f636f6465636f762e696f2f67682f676c75676f782f6d616769632f6272616e63682f6d61696e2f67726170682f62616467652e737667)

A Laravel code generator that turns JSON entity definitions into a working application or a reusable Composer package. Magic wires migrations, models, controllers, Vue/Inertia pages, tests, and boilerplate Laravel setup so you can prototype or bootstrap production features in minutes.

[![Magic build workflow](magic-demo.svg)](magic-demo.svg)

---

Table of contents
-----------------

[](#table-of-contents)

1. [What Magic does](#what-magic-does)
2. [Requirements](#requirements)
3. [Installation](#installation)
4. [Running the generator](#running-the-generator)
5. [Understanding configuration](#understanding-configuration)
6. [Package mode](#package-mode)
7. [File generation reference](#file-generation-reference)
8. [Resetting a build](#resetting-a-build)
9. [Customising stubs &amp; namespaces](#customising-stubs--namespaces)
10. [Testing and quality tools](#testing-and-quality-tools)
11. [Troubleshooting](#troubleshooting)
12. [Contributing](#contributing)
13. [License](#license)

---

What Magic does
---------------

[](#what-magic-does)

Magic reads a JSON schema that describes your domain (entities, relations, presets, UI metadata) and executes a predictable build pipeline:

1. Resolve configuration and normalise paths.
2. Publish starter assets and language files.
3. Install the required Composer and NPM dependencies (host builds only).
4. Generate migrations, models, enums, factories, seeders, REST controllers, form requests, API resources, TypeScript definitions, Vue pages, and Pest tests.
5. Register routes, Sanctum middleware, queues, and Inertia bootstrapping when targeting a Laravel application.
6. Produce a manifest of generated files so resets can be executed safely.

Every build step is implemented as a dedicated action under `src/Actions/Build`, making the pipeline easy to extend or re-order for your own needs.

---

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

[](#requirements)

RequirementVersionPHP^8.4Laravel10.x – 12.xNode.js &amp; npmRequired for front-end scaffoldingComposerLatest stable> **Tip:** Magic ships as a regular Laravel package. You can install it globally in a host Laravel app or use package mode to generate a standalone Composer package that you pull into multiple projects.

---

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

[](#installation)

### Install into a Laravel application

[](#install-into-a-laravel-application)

1. Create or open a Laravel application that already has Breeze/Inertia (Vue) installed.
2. Require Magic as a dev dependency: ```
    composer require glugox/magic --dev
    ```
3. Publish the configuration file: ```
    php artisan vendor:publish --provider="Glugox\\Magic\\MagicServiceProvider"
    ```
4. Optional: explore the sample configurations in `stubs/samples`.

### Install for package generation

[](#install-for-package-generation)

If you plan to generate re-usable features as a package, install Magic in a throwaway Laravel project and run the generator with the package flags (described below). Magic will emit a new Composer package that you can require in your real application.

---

Running the generator
---------------------

[](#running-the-generator)

Magic exposes one primary Artisan command:

```
php artisan magic:build [options]
```

OptionDescription`--config=`Absolute or relative path to a JSON configuration file.`--starter=`Name of a starter config shipped with Magic (e.g. `inventory`, `task`).`--set=`Inline overrides using dot notation (`--set=app.name="Acme"`). Repeatable.`--package-path=`Destination directory for Composer package builds. Creates the folder if missing.`--package-namespace=`Root PSR-4 namespace to use when generating a package (e.g. `Acme\Inventory`).`--package-name=`Composer package name for package builds (e.g. `acme/inventory-kit`).Examples:

```
# Generate directly into the Laravel application
php artisan magic:build --starter=inventory

# Generate a package under ./packages/inventory-kit
php artisan magic:build \
  --config=stubs/samples/inventory.json \
  --package-path=packages/inventory-kit \
  --package-namespace=Acme\\Inventory \
  --package-name=acme/inventory-kit
```

Magic prevents accidental overwrites by checking for `storage/magic/generated_files.json`. Run `php artisan magic:reset` (see below) before triggering a new build in the same environment.

---

Understanding configuration
---------------------------

[](#understanding-configuration)

- Configuration files follow `json-schema.json` and can be validated automatically by most editors.
- Each config declares global app metadata (name, base namespace overrides, Faker mappings, seeding flags) and an array of entities.
- Entities describe fields, relations, filters, table presets, navigation icons, and test scenarios.
- Sample configs live in [`stubs/samples`](stubs/samples); the `inventory.json` example demonstrates most features.

A minimal entity definition:

```
{
  "app": {
    "name": "Inventory",
    "seedEnabled": true
  },
  "entities": [
    {
      "name": "Product",
      "icon": "Package",
      "fields": [
        { "name": "name", "type": "string", "rules": ["required"] },
        { "name": "sku", "type": "string", "unique": true },
        { "name": "price", "type": "decimal", "precision": 12, "scale": 2 }
      ],
      "relations": [
        { "type": "belongsTo", "name": "category", "entity": "Category" }
      ]
    }
  ]
}
```

When a build runs, the configuration is parsed into strongly typed objects (`src/Support/Config`) so generators can reason about default values and relationships safely.

---

Package mode
------------

[](#package-mode)

Package mode rewires Magic so that **every generated file lands inside a Composer package** instead of your Laravel app. Three options must be provided: `--package-path`, `--package-namespace`, and `--package-name`.

Key behaviours:

- `MagicPaths` swaps Laravel helpers (app\_path, database\_path, etc.) for equivalents rooted inside the target package directory.
- `MagicNamespaces` ensures PHP namespaces resolve under your chosen base namespace (controllers, models, resources, providers, and tests are all updated).
- `InitializePackageAction` prepares the destination by creating a Laravel-like directory tree, generating a Composer manifest with PSR-4 autoloading, and scaffolding a `MagicPackageServiceProvider` that registers routes, views, migrations, and translations when installed into a host app.
- Host-only steps—environment tweaks, dependency installation, queue setup, Sanctum middleware mutations, and Vue bootstrapping—are skipped so the package remains framework-agnostic.
- Seeders generated inside a package avoid touching `DatabaseSeeder.php`; consumers can opt-in by calling the package service provider’s seeders manually.

After running the generator in package mode:

1. Commit the generated package to its own repository (or keep it inside a monorepo under `packages/`).
2. Require it from your real Laravel application via VCS or path repositories.
3. Register the generated service provider if you disable Laravel’s automatic package discovery.

Example of generating a package called `glugox/module-a` with the `orchestrator` starter:

```
php artisan magic:build --package-path ./modules/glugox/module-a --package-name glugox/module-a --package-namespace Glugox\\ModuleA --starter orchestrator
```

---

File generation reference
-------------------------

[](#file-generation-reference)

AreaWhat gets generated**Database**Timestamped migrations, model factories, individual seeders.**Domain**Eloquent models, relationships, query scopes, enums, Meta classes, console commands for entity actions.**HTTP layer**API controllers, form requests, API resources, routes (`routes/app.php`, `routes/app/api.php`) and attachable asset support.**Front-end**Vue 3 pages (index, create, edit, detail), shared components, TypeScript DTOs, lucide icon imports, composables.**Testing**Pest feature tests for CRUD operations, HTTP tests, and package-specific coverage.**DevOps**Magic manifest under `storage/magic`, queue installation helpers, `.env` updates (host builds only).Refer to the corresponding action classes in `src/Actions/Build` for implementation details.

---

Resetting a build
-----------------

[](#resetting-a-build)

Use the reset command when you need to revert the generated artefacts inside a Laravel application:

```
php artisan magic:reset --starter=inventory
```

`magic:reset` replays the manifest from `storage/magic/generated_files.json`, deletes migrations, models, seeders, controllers, Vue pages, TypeScript artefacts, and restores modified Laravel files to their original state before optionally refreshing the database. Package builds can be reset manually by deleting the destination directory and re-running `magic:build`.

---

Customising stubs &amp; namespaces
----------------------------------

[](#customising-stubs--namespaces)

- All PHP and Vue stubs live under [`stubs/`](stubs); copy them into your application and update `config/magic.php` if you need to override defaults.
- `MagicNamespaces` lets you change the base namespace for generated classes. Provide the `--package-namespace` option or edit the configuration’s `app.namespace` value when targeting a Laravel app.
- `MagicPaths` centralises every filesystem lookup so package builds, tests, and workbench usage stay isolated. Clearing paths/namespaces after each command prevents leakage into subsequent Artisan calls.

---

Testing and quality tools
-------------------------

[](#testing-and-quality-tools)

The project uses Pest, PHPStan, Laravel Pint, and Rector. Run everything locally with:

```
composer install
composer test      # pest + pint --test
composer analyse   # phpstan
composer format    # pint (fixes)
```

When contributing, make sure your feature and unit tests cover new behaviour—especially when altering generators or stubs.

---

Troubleshooting
---------------

[](#troubleshooting)

- **`Manifest file exist` error** – run `php artisan magic:reset` before starting a new build in the same Laravel project.
- **Missing Vue components in package builds** – Magic scaffolds Vue files from built-in stubs when `resources/js/components/AppSidebar.vue` or `AppLogo.vue` is absent.
- **Routes not registered after installing a package** – confirm that the generated `MagicPackageServiceProvider` is discovered (Composer autoload dump + Laravel package discovery) and that `routes/app.php` and `routes/app/api.php` exist in your package.
- **Need to skip seeding in a package** – by design Magic avoids touching `DatabaseSeeder.php` during package builds; call package seeders manually from the consuming app if required.

---

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

[](#contributing)

Issues and pull requests are welcome! If you are planning a large change, please open an issue first so we can discuss scope and direction. When submitting a PR:

1. Add or update tests.
2. Run the QA commands listed above.
3. Document user-facing changes in this README or the changelog.

You can also reach out directly at .

---

License
-------

[](#license)

Magic is open-sourced software licensed under the [MIT license](LICENSE.md).

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance60

Regular maintenance activity

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 86% 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 ~13 days

Total

5

Last Release

258d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

build-toolcommand-line-toollarvelphp84laravelmagicglugox

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M194](/packages/laravel-ai)[codewithdennis/filament-select-tree

The multi-level select field enables you to make single selections from a predefined list of options that are organized into multiple levels or depths.

329530.5k29](/packages/codewithdennis-filament-select-tree)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

124603.0k](/packages/worksome-exchange)[elegantly/laravel-translator

All on one translations management for Laravel

6333.1k](/packages/elegantly-laravel-translator)[atlas-php/atlas

A unified AI SDK for Laravel applications.

5345.4k](/packages/atlas-php-atlas)

PHPackages © 2026

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