Skip to content

Getting Started

Laravel API Generator scaffolds a complete, production-style REST API from a single artisan command: model, migration, controller, service, DTO, form request, resource, policy, factory, seeder and written tests.

The same entity by hand takes about two hours; make:fullapi does it in thirty seconds

Requirements

  • PHP >= 8.2 (>= 8.3 for Laravel 13)
  • Laravel 10.x, 11.x, 12.x or 13.x

Installation

bash
composer require --dev nameless/laravel-api-generator

The service provider is auto-discovered. No configuration required.

Zero lock-in

The generator is a dev dependency: it never runs in production (composer install --no-dev leaves it out), and the generated code is plain Laravel with no dependency on this package (no base classes, no runtime helpers). You can even remove the generator afterwards and everything keeps working.

Your first API

bash
php artisan make:fullapi Post --fields="title:string,content:text,published:boolean"

Then:

bash
php artisan migrate
php artisan test

The suite passes right after generation, with real assertions against real endpoints, where most generators leave you skeletons to fill in.

What gets generated

One command creates 12 files per entity and registers the API route:

LayerFileLocation
ModelPost.phpapp/Models/
ControllerPostController.phpapp/Http/Controllers/
ServicePostService.phpapp/Services/
DTOPostDTO.phpapp/DTO/
RequestPostRequest.phpapp/Http/Requests/
ResourcePostResource.phpapp/Http/Resources/
PolicyPostPolicy.phpapp/Policies/
FactoryPostFactory.phpdatabase/factories/
SeederPostSeeder.phpdatabase/seeders/
Migration*_create_posts_table.phpdatabase/migrations/
Feature TestPostControllerTest.phptests/Feature/
Unit TestPostServiceTest.phptests/Unit/
RouteapiResource entryroutes/api.php

The generated architecture

Every request flows through a clean, layered structure:

The controller stays thin and delegates to the service:

php
public function store(PostRequest $request)
{
    $dto = PostDTO::fromRequest($request);
    $post = $this->service->create($dto);

    return new PostResource($post);
}

Business logic lives in PostService, data crosses layers as a typed, readonly PostDTO. When your API grows, the right places to put things already exist.

Models your IDE understands

Every generated model ships a complete PHPDoc block: fields, FK columns, relations, timestamps:

php
/**
 * @property int $id
 * @property string $title
 * @property \App\Enums\Status $status
 * @property \Illuminate\Support\Carbon|null $published_at
 * @property-read \Illuminate\Database\Eloquent\Collection<int, Comment> $comments
 */
class Post extends Model

Autocomplete works instantly in VS Code and PhpStorm, without ide-helper for the generated code.

Next steps