PHPackages                             coresuit/migration-gen-laravel - 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. [Database &amp; ORM](/categories/database)
4. /
5. coresuit/migration-gen-laravel

ActiveLibrary[Database &amp; ORM](/categories/database)

coresuit/migration-gen-laravel
==============================

Gerador de migrations por entidade e campos (CoreSuit style) para Laravel

v2.0.4(4mo ago)03MITPHPPHP &gt;=8.2

Since Dec 27Pushed 4mo agoCompare

[ Source](https://github.com/jeananjos0/coresuit-migration-gen-laravel)[ Packagist](https://packagist.org/packages/coresuit/migration-gen-laravel)[ RSS](/packages/coresuit-migration-gen-laravel/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (5)Used By (0)

CoreSuit Migration Gen (Laravel)
================================

[](#coresuit-migration-gen-laravel)

Gerador de **Migration + Model + Repository/Interface + Service/Interface + Requests + Controller** com **injeção automática de Rotas e Providers** para projetos Laravel — no estilo **CoreSuit**.

> Compatível com Laravel 11/12+ e PHP &gt;= 8.2

---

Sumário
-------

[](#sumário)

- [Instalação no seu projeto (consumidor)](#instala%C3%A7%C3%A3o-no-seu-projeto-consumidor)
- [Primeiros passos (init)](#primeiros-passos-init)
- [Como gerar uma entidade](#como-gerar-uma-entidade)
- [Sintaxe de campos (`--fields`)](#sintaxe-de-campos---fields)
- [Arquivos e estrutura gerada](#arquivos-e-estrutura-gerada)
- [Customização com stubs e namespaces](#customiza%C3%A7%C3%A3o-com-stubs-e-namespaces)
- [Injeção de rotas e providers](#inje%C3%A7%C3%A3o-de-rotas-e-providers)
- [Comandos disponíveis](#comandos-dispon%C3%ADveis)
- [Como usar o pacote em outro projeto Laravel](#como-usar-o-pacote-em-outro-projeto-laravel)
- [Como publicar uma nova versão no Packagist (maintainer)](#como-publicar-uma-nova-vers%C3%A3o-no-packagist-maintainer)
- [Boas práticas de versionamento](#boas-pr%C3%A1ticas-de-versionamento)
- [Solução de problemas (FAQ)](#solu%C3%A7%C3%A3o-de-problemas-faq)
- [Licença](#licen%C3%A7a)

---

Instalação no seu projeto (consumidor)
--------------------------------------

[](#instalação-no-seu-projeto-consumidor)

> **Pré-requisitos**: Projeto Laravel com Composer configurado.

Instale a versão estável mais recente:

```
composer require coresuit/migration-gen-laravel
```

Ou uma faixa específica (ex.: série 1.3):

```
composer require coresuit/migration-gen-laravel:^1.3
```

Se (temporariamente) você precisa testar a branch de desenvolvimento:

```
composer require coresuit/migration-gen-laravel:dev-master
```

> **Não recomendado para produção.**

---

Primeiros passos (`init`)
-------------------------

[](#primeiros-passos-init)

Antes de gerar entidades, execute o **init** para preparar bases de Repository/Service/DTO/Requests/Controller, registrar **Providers**, criar **OpenAPI bootstrap** e rota de **health**.

```
php artisan coresuit:make-migration init
```

O que o `init` faz:

- Cria bases em:
    - `app/Repositories`, `app/Services`, `app/DTOs/Shared`
    - `app/Http/Requests/Shared`, `app/Http/Controllers/Shared`
- Cria `app/OpenApi/OpenApi.php` (bootstrap OpenAPI).
- Registra providers (`RepositoryServiceProvider` e `ServicesServiceProvider`) usando marcador `[coresuit_providers]`.
- Gera rota `/api/health` e controller de health check.
- Cria flag `bootstrap/cache/coresuit_init.flag` que libera o gerador.

> **Swagger (opcional)**: para documentação da API com L5 Swagger

```
composer require darkaonline/l5-swagger
php artisan package:discover --ansi
php artisan l5-swagger:generate
# A doc padrão fica em /api/documentation
```

---

Como gerar uma entidade
-----------------------

[](#como-gerar-uma-entidade)

Exemplo criando **Pedido** com campos e relacionamentos:

```
php artisan coresuit:make-entity \
  --name=Pedido \
  --fields="cliente_id:int:true,data_pedido:date:true,observacao:text:false,valor_total:decimal:true,ativo:boolean:false"
```

Depois, aplique a migration:

```
php artisan migrate
```

### O que é criado

[](#o-que-é-criado)

- **Migration**: `database/migrations/_create_pedidos_table.php`
- **Model**: `app/Models/Pedido.php`
- **Repository + Interface**
- **Service + Interface**
- **Requests** (List/Store/Update)
- **Controller** REST
- **Rotas** (prefixo `pedido` por padrão)
- **Providers** (binds automáticos)

---

Sintaxe de campos (`--fields`)
------------------------------

[](#sintaxe-de-campos---fields)

Formato: `nome:type:required`, separados por vírgula.

- **nome**: será normalizado para `snake_case`.
- **type**: `string`, `text`, `int`/`integer`, `bigint`, `decimal`, `bool`/`boolean`, `date`, `datetime`, `json`.
- **required**: `true` | `false` (controla `nullable()` e validações).

Exemplo completo:

```
cliente_id:int:true,observacao:text:false,valor_total:decimal:true,ativo:boolean:false,data_pedido:date:true

```

**Regra especial**: campos que terminam com **`_id`**

- Geram `belongsTo` automaticamente no Model (ex.: `cliente()`).
- Criam foreign key na migration (`references('id')->on('clientes')`).

Impactos por tipo:

- **Migration**: `string`, `text`, `unsignedInteger`, `unsignedBigInteger`, `decimal(18,2)`, `boolean`, `date`, `dateTime`, `json`.
- **Model**: adiciona **casts** adequados (ex.: `decimal:2`, `boolean`, `array`, `date`, `datetime`).
- **Requests**: validações, sanitização (ex.: trim/boolean) e filtros no `ListRequest` (query params `filters[...]`).

---

Arquivos e estrutura gerada
---------------------------

[](#arquivos-e-estrutura-gerada)

```
app/
  DTOs/Shared/IndexQueryDTO.php
  Http/
    Controllers/
      Shared/BaseController.php
      System/Controller.php
    Requests/
      Shared/{BaseIndexRequest,IndexRequest}.php
      /{ListRequest,StoreRequest,UpdateRequest}.php
  Models/.php
  OpenApi/OpenApi.php
  Providers/{RepositoryServiceProvider,ServicesServiceProvider}.php
  Repositories/
    Contracts/{IBaseRepository.php,IRepository.php}
    /Repository.php
  Services/
    Shared/{BaseService.php,IBaseService.php}
    /{IService.php,Service.php}

routes/api.php     # contém // [router_marckenew_generates]
bootstrap/cache/coresuit_init.flag

```

---

Customização com stubs e namespaces
-----------------------------------

[](#customização-com-stubs-e-namespaces)

Você pode **apontar stubs personalizados** e **alterar namespaces/diretórios**:

```
php artisan coresuit:make-entity \
  --name=Produto \
  --fields="nome:string:true,preco:decimal:true,categoria_id:int:false" \
  --stub-migration=stubs/coresuit/migration.stub \
  --stub-model=stubs/coresuit/model.stub \
  --stub-repository=stubs/coresuit/repository.stub \
  --stub-irepository=stubs/coresuit/irepository.stub \
  --stub-service=stubs/coresuit/service.stub \
  --stub-iservice=stubs/coresuit/iservice.stub \
  --stub-request_list=stubs/coresuit/request_list.stub \
  --stub-request_store=stubs/coresuit/request_store.stub \
  --stub-request_update=stubs/coresuit/request_update.stub \
  --stub-controller=stubs/coresuit/controller.stub \
  --model-namespace="App\\Models" \
  --repo-namespace="App\\Repositories" \
  --contracts-namespace="App\\Repositories\\Contracts" \
  --repo-dir="app/Repositories" \
  --contracts-dir="app/Repositories/Contracts" \
  --base-repo="App\\Repositories\\Shared\\BaseRepository" \
  --base-irepo="App\\Repositories\\Contracts\\IBaseRepository" \
  --service-namespace="App\\Services" \
  --service-dir="app/Services" \
  --base-service="App\\Services\\Shared\\BaseService" \
  --base-iservice="App\\Services\\Shared\\IBaseService" \
  --requests-namespace="App\\Http\\Requests" \
  --requests-dir="app/Http/Requests" \
  --base-index-request="App\\Http\\Requests\\Shared\\BaseIndexRequest" \
  --base-form-request="Illuminate\\Foundation\\Http\\FormRequest" \
  --controller-namespace="App\\Http\\Controllers\\System" \
  --controller-dir="app/Http/Controllers/System" \
  --route-prefix="produto" \
  --tag="Produto"
```

Flags úteis: `--no-migration`, `--no-model`, `--no-repo`, `--no-service`, `--no-requests`, `--no-controller`, `--no-routes`, `--no-providers`, `--force`.

---

Injeção de rotas e providers
----------------------------

[](#injeção-de-rotas-e-providers)

**Rotas** (em `routes/api.php`) com grupo de middleware (default `auth.jwt`) e marcador:

```
Route::prefix('pedido')->controller(PedidoController::class)->group(function () {
    Route::get('/', 'index');
    Route::get('{id}', 'show')->whereNumber('id');
    Route::post('/', 'store');
    Route::put('{id}', 'update')->whereNumber('id');
    Route::delete('{id}', 'destroy')->whereNumber('id');
    Route::post('{id}/restore', 'restore')->whereNumber('id');
    Route::delete('{id}/force', 'forceDelete')->whereNumber('id');
});
```

**Providers**: binds injetados em `RepositoryServiceProvider` e `ServicesServiceProvider` abaixo do marcador `// [coresuit_providers]`.

---

Comandos disponíveis
--------------------

[](#comandos-disponíveis)

- `php artisan coresuit:make-migration init` — prepara o projeto (bases, providers, OpenAPI, health, flag).
- `php artisan coresuit:make-entity --name=... --fields="..."` — gera stack CRUD.

Ajuda rápida:

```
php artisan list | grep coresuit
php artisan help coresuit:make-entity
```

---

Como usar o pacote em outro projeto Laravel
-------------------------------------------

[](#como-usar-o-pacote-em-outro-projeto-laravel)

1. **Instale o pacote**: ```
    composer require coresuit/migration-gen-laravel
    ```
2. **Execute o init** (uma vez por projeto): ```
    php artisan coresuit:make-migration init
    ```
3. **Gere entidades** conforme necessidade: ```
    php artisan coresuit:make-entity --name=Cliente --fields="nome:string:true,documento:string:false,ativo:boolean:false"
    php artisan migrate
    ```
4. **Customize** (opcional): publique stubs para editar templates ```
    php artisan vendor:publish --tag=coresuit-stubs
    # edite em stubs/coresuit/*.stub
    ```

---

Como publicar uma nova versão no Packagist (maintainer)
-------------------------------------------------------

[](#como-publicar-uma-nova-versão-no-packagist-maintainer)

> Para o **mantenedor** do pacote.

1. Garanta commits na `master`: ```
    git add .
    git commit -m "feat: nova funcionalidade"
    git push origin master
    ```
2. **Crie a tag semântica** e envie: ```
    git tag -a v1.3.0 -m "Release 1.3.0"
    git push origin v1.3.0
    ```
3. **Atualize no Packagist**:
    - Manual: botão **Update** na página do pacote; **ou**
    - Automático (recomendado): Configure um **webhook** no GitHub
        - Settings → Webhooks → **Add webhook**
        - **Payload URL**: `https://packagist.org/api/github`
        - **Content type**: `application/json`
        - **Events**: *Just the push event*

**Importante**: evite manter `"version"` no `composer.json`. Deixe o Packagist inferir a versão pela **tag**.
Se optar por manter `"version"`, ela **deve** ser exatamente igual à tag (ex.: `1.3.0`).

**Corrigir tag equivocada**:

```
git tag -d v1.2.9
git push origin :refs/tags/v1.2.9
git tag -a v1.2.9 COMMIT_HASH -m "Release 1.2.9"
git push origin v1.2.9
```

---

Boas práticas de versionamento
------------------------------

[](#boas-práticas-de-versionamento)

- **MAJOR** `2.0.0`: mudanças que quebram compatibilidade.
- **MINOR** `1.3.0 -> 1.4.0`: novas features compatíveis.
- **PATCH** `1.3.0 -> 1.3.1`: correções e micro melhorias.
- Use CHANGELOG (Releases do GitHub) para destacar mudanças.

---

Solução de problemas (FAQ)
--------------------------

[](#solução-de-problemas-faq)

**“Could not find a version matching your minimum-stability (stable)”**

- Publique uma tag estável (ex.: `v1.0.0`) OU instale `:dev-master` temporariamente.
- Alternativa: ```
    {
      "minimum-stability": "dev",
      "prefer-stable": true
    }
    ```

**“Some tags were ignored because of a version mismatch in composer.json”**

- Remova `"version"` do `composer.json` ou sincronize com a tag.
- Clique **Update** no Packagist (ou configure webhook).

**“Not auto-updated” no Packagist**

- Ative o webhook do GitHub: `https://packagist.org/api/github` (evento `push`).

**“tag already exists” ao criar nova tag**

```
git tag -d vX.Y.Z
git push origin :refs/tags/vX.Y.Z
git tag -a vX.Y.Z -m "Release X.Y.Z"
git push origin vX.Y.Z
```

**`coresuit:make-entity` acusa que init não foi executado**

- Rode: `php artisan coresuit:make-migration init`

---

Licença
-------

[](#licença)

MIT — ver `LICENSE`.

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance75

Regular maintenance activity

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity50

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

Every ~0 days

Total

4

Last Release

136d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/329e32e4da263cbf881eb83bd3a50c9adcc0f74879231db32c262d58a6841883?d=identicon)[jeananjos0](/maintainers/jeananjos0)

---

Top Contributors

[![JeanAnjos](https://avatars.githubusercontent.com/u/61751401?v=4)](https://github.com/JeanAnjos "JeanAnjos (7 commits)")

### Embed Badge

![Health badge](/badges/coresuit-migration-gen-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/coresuit-migration-gen-laravel/health.svg)](https://phpackages.com/packages/coresuit-migration-gen-laravel)
```

###  Alternatives

[spatie/laravel-backup

A Laravel package to backup your application

6.0k21.8M191](/packages/spatie-laravel-backup)[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M26](/packages/tucker-eric-eloquentfilter)[cybercog/laravel-clickhouse

ClickHouse migrations for Laravel

163166.8k](/packages/cybercog-laravel-clickhouse)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)[toponepercent/baum

Baum is an implementation of the Nested Set pattern for Eloquent models.

3154.7k](/packages/toponepercent-baum)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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