PHPackages                             laravel-enso/migrator - 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. laravel-enso/migrator

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

laravel-enso/migrator
=====================

Structure-aware migration helpers for Laravel Enso packages

2.5.2(2mo ago)143.7k↓15.7%320MITPHP

Since May 17Pushed 2mo ago3 watchersCompare

[ Source](https://github.com/laravel-enso/migrator)[ Packagist](https://packagist.org/packages/laravel-enso/migrator)[ Docs](https://github.com/laravel-enso/migrator)[ RSS](/packages/laravel-enso-migrator/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (8)Versions (31)Used By (20)

Migrator
========

[](#migrator)

[![License](https://camo.githubusercontent.com/54571f5bd5573b7ab134551bb40fcd30a33514e3d25e6a8a71edb9a5514fb0e6/68747470733a2f2f706f7365722e707567782e6f72672f6c61726176656c2d656e736f2f6d69677261746f722f6c6963656e7365)](https://github.com/laravel-enso/migrator/blob/master/LICENSE)[![Stable](https://camo.githubusercontent.com/8dcef41fbaebb5d52408e4fe03cb5aebdd703949d96592b8354decc7970f5352/68747470733a2f2f706f7365722e707567782e6f72672f6c61726176656c2d656e736f2f6d69677261746f722f76657273696f6e)](https://packagist.org/packages/laravel-enso/migrator)[![Downloads](https://camo.githubusercontent.com/ddbf8862622d96c67b96cf8e945dcd04973054c319b0535efa32d101957621d2/68747470733a2f2f706f7365722e707567782e6f72672f6c61726176656c2d656e736f2f6d69677261746f722f646f776e6c6f616473)](https://packagist.org/packages/laravel-enso/migrator)[![PHP](https://camo.githubusercontent.com/76d2504e4f304c14866dd7295641dd6812652d93a1848a27fc8e2a08d6732731/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382e332532422d3737376262342e737667)](https://github.com/laravel-enso/migrator/blob/master/composer.json)[![Issues](https://camo.githubusercontent.com/4f2f670cfa2294d5b0fff85bb4ea53ba42ead2349516f92ac4a08f9b17f21ed5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6c61726176656c2d656e736f2f6d69677261746f722e737667)](https://github.com/laravel-enso/migrator/issues)[![Merge Requests](https://camo.githubusercontent.com/6095f33cc889e3c8d81fe3d6448afe2f5934113fed95c62c421906c6e01d9d32/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732d70722f6c61726176656c2d656e736f2f6d69677261746f722e737667)](https://github.com/laravel-enso/migrator/pulls)

Description
-----------

[](#description)

Migrator provides a structure-aware migration helper for Laravel Enso packages.

The package exposes an abstract migration base class that wraps permission creation and menu creation into the normal Laravel migration lifecycle. It is intended for Enso packages that need to register permissions and menu entries together with the database changes that introduce a new module or page.

Instead of duplicating the same permission and menu provisioning logic in each package, Enso migrations can declare a permission array, a menu payload, and an optional parent menu path, and let the package handle validation, creation, and rollback.

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

[](#installation)

This package is normally installed as part of the Enso backend stack.

For standalone installation in an Enso-based application:

```
composer require laravel-enso/migrator
```

The package depends on:

- `laravel-enso/core`
- `laravel-enso/menus`
- `laravel-enso/permissions`
- `laravel-enso/roles`

Features
--------

[](#features)

- Abstract migration class for permission and menu provisioning.
- Transaction-wrapped `up()` and `down()` flows.
- Permission creation with default-role and all-roles assignment logic.
- Menu creation linked automatically to the declared route permission.
- Parent menu resolution through dot-notated menu paths.
- Validation for required permission and menu attributes.
- Structure-specific exceptions for invalid elements or unresolved parents.

Usage
-----

[](#usage)

Extend `LaravelEnso\Migrator\Database\Migration` in a package migration:

```
use LaravelEnso\Migrator\Database\Migration;

return new class extends Migration {
    protected array $permissions = [
        ['name' => 'examples.index', 'description' => 'List examples', 'is_default' => true],
        ['name' => 'examples.create', 'description' => 'Create an example', 'is_default' => false],
    ];

    protected array $menu = [
        'name' => 'Examples',
        'icon' => 'fas fa-flask',
        'route' => 'examples.index',
        'order_index' => 999,
        'has_children' => false,
    ];

    protected ?string $parentMenu = 'administration';
};
```

When the migration runs:

- `up()` creates the declared permissions
- default permissions are attached to every role
- non-default permissions are attached only to the configured default role
- the menu entry is created and linked to the permission behind the declared route

When the migration rolls back:

- the menu entry is removed first
- the permissions are deleted afterwards

API
---

[](#api)

### Abstract Migration

[](#abstract-migration)

`LaravelEnso\Migrator\Database\Migration`

Protected properties:

- `protected array $permissions = []`
- `protected array $menu = []`
- `protected ?string $parentMenu = null`

Lifecycle methods:

- `up()`
- `down()`

Both directions are executed inside a database transaction.

### Permission Payload

[](#permission-payload)

Each permission entry must contain:

- `name`
- `description`
- `is_default`

Behavior:

- `is_default = true` attaches the permission to all roles
- `is_default = false` attaches it only to the configured default role from `enso.config.defaultRole`

### Menu Payload

[](#menu-payload)

The menu payload must contain:

- `name`
- `icon`
- `route`
- `order_index`
- `has_children`

Behavior:

- `route` is used to resolve the matching permission
- the permission id is stored on the created menu
- `route` itself is removed from the persisted menu payload after resolution

### Services

[](#services)

Main services:

- `LaravelEnso\Migrator\Services\Permissions`
- `LaravelEnso\Migrator\Services\Menus`
- `LaravelEnso\Migrator\Services\ParentMenu`
- `LaravelEnso\Migrator\Services\Validator`

### Parent Menu Resolution

[](#parent-menu-resolution)

`ParentMenu` accepts a dot-notated menu chain such as:

```
'administration.settings'
```

It resolves the menu from the last segment upwards and throws when the full ancestry chain cannot be matched.

### Exceptions

[](#exceptions)

The package throws `LaravelEnso\Migrator\Exceptions\EnsoStructure` for:

- invalid permission or menu payload types
- missing required attributes
- unresolved parent menu paths

Depends On
----------

[](#depends-on)

Required Enso packages:

- [`laravel-enso/core`](https://docs.laravel-enso.com/backend/core.html) [↗](https://github.com/laravel-enso/core)
- [`laravel-enso/menus`](https://docs.laravel-enso.com/backend/menus.html) [↗](https://github.com/laravel-enso/menus)
- [`laravel-enso/permissions`](https://docs.laravel-enso.com/backend/permissions.html) [↗](https://github.com/laravel-enso/permissions)
- [`laravel-enso/roles`](https://docs.laravel-enso.com/backend/roles.html) [↗](https://github.com/laravel-enso/roles)

Contributions
-------------

[](#contributions)

are welcome. Pull requests are great, but issues are good too.

Thank you to all the people who already contributed to Enso!

###  Health Score

57

—

FairBetter than 98% of packages

Maintenance86

Actively maintained with recent releases

Popularity31

Limited adoption so far

Community35

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~110 days

Recently: every ~204 days

Total

24

Last Release

73d ago

Major Versions

1.1.7 → 2.0.02020-06-25

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/16073274?v=4)[Adrian Ocneanu](/maintainers/aocneanu)[@aocneanu](https://github.com/aocneanu)

---

Top Contributors

[![aocneanu](https://avatars.githubusercontent.com/u/16073274?v=4)](https://github.com/aocneanu "aocneanu (24 commits)")[![gandesc](https://avatars.githubusercontent.com/u/14071925?v=4)](https://github.com/gandesc "gandesc (12 commits)")[![vmcvlad](https://avatars.githubusercontent.com/u/37445394?v=4)](https://github.com/vmcvlad "vmcvlad (4 commits)")[![raftx24](https://avatars.githubusercontent.com/u/10864136?v=4)](https://github.com/raftx24 "raftx24 (3 commits)")[![AbdullahiAbdulkabir](https://avatars.githubusercontent.com/u/33360580?v=4)](https://github.com/AbdullahiAbdulkabir "AbdullahiAbdulkabir (3 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (2 commits)")[![GITmanuela](https://avatars.githubusercontent.com/u/44998004?v=4)](https://github.com/GITmanuela "GITmanuela (2 commits)")[![tedipop16](https://avatars.githubusercontent.com/u/71398467?v=4)](https://github.com/tedipop16 "tedipop16 (1 commits)")

---

Tags

ensolaravellaravel-ensomigrationsmigratorlaravel-ensoStructuresenso-helper

### Embed Badge

![Health badge](/badges/laravel-enso-migrator/health.svg)

```
[![Health](https://phpackages.com/badges/laravel-enso-migrator/health.svg)](https://phpackages.com/packages/laravel-enso-migrator)
```

###  Alternatives

[laravel-enso/core

The backend shell of a Laravel Enso application

3465.3k205](/packages/laravel-enso-core)[laravel-enso/cli

Interactive scaffolding for Laravel Enso resources

1039.5k](/packages/laravel-enso-cli)[laravel-enso/menus

Menu management for Laravel Enso

1644.0k25](/packages/laravel-enso-menus)[laravel-enso/tutorials

Tutorial management backend for Laravel Enso

1140.7k](/packages/laravel-enso-tutorials)[laravel-enso/roles

Role management for Laravel Enso

1044.9k32](/packages/laravel-enso-roles)[laravel-enso/permissions

Permission management for Laravel Enso

1244.2k51](/packages/laravel-enso-permissions)

PHPackages © 2026

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