---
url: /laravel-api-generator/guide/generating.md
---
# The `make:fullapi` Command

`make:fullapi` is the heart of the package. It accepts an entity name with inline fields, or reads from a [schema file](/guide/schema-files), a [Mermaid diagram](/guide/mermaid) or your [existing database](/guide/from-database).

## Basic usage

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

## Soft deletes

```bash
php artisan make:fullapi Post --fields="title:string,content:text" --soft-deletes
```

Adds the `SoftDeletes` trait, a `softDeletes()` migration column, `restore()` / `forceDelete()` methods, and two extra routes that still find a soft deleted post:

```
POST   /api/posts/{post}/restore
DELETE /api/posts/{post}/force-delete
```

## Sanctum authentication

```bash
php artisan make:fullapi Post --fields="title:string" --auth
```

Scaffolds a complete token-based auth system: `AuthController` (register, login, logout, user), `LoginRequest`, `RegisterRequest`, public auth routes, and wraps your API resource routes inside `auth:sanctum` middleware.

| Method | Route | Access |
|--------|-------|--------|
| `POST` | `/api/register` | Public, limited to 6 requests per minute |
| `POST` | `/api/login` | Public, limited to 6 requests per minute |
| `POST` | `/api/logout` | `auth:sanctum` |
| `GET` | `/api/user` | `auth:sanctum` |
| `GET` | `/api/posts` | `auth:sanctum` (your resources require a token too) |

Then install Sanctum if not already present:

```bash
composer require laravel/sanctum
php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider"
php artisan migrate
```

## Postman collection

```bash
php artisan make:fullapi Post --fields="title:string" --postman
```

Exports a `postman_collection.json` (v2.1 schema) at the project root: a folder per entity with List, Create, Show, Update and Delete requests pre-filled with sample data. See [API Docs & Postman](/guide/docs-and-postman).

## Pagination, filters and sorting

Every generated `index` endpoint is paginated, filterable and sortable:

```
GET /api/posts?filter[status]=draft&sort=-created_at,title&page=2&per_page=20
```

The response carries `data`, `links` and `meta`. Filters match exact values on the primary key and the fillable columns (JSON columns excluded). `sort` takes a comma-separated list where a leading `-` means descending, and the default order is the primary key, newest first. Unknown filters and sorts are ignored.

`per_page` defaults to 15 and stops at 100. To change these values, publish the config before generating. They are written into each generated service, so the generated code never reads the package at runtime.

```bash
php artisan vendor:publish --tag=api-generator-config
```

### With Spatie QueryBuilder

```bash
composer require spatie/laravel-query-builder
php artisan make:fullapi Post --fields="title:string,content:text" --query-builder
```

The same parameters then go through [spatie/laravel-query-builder](https://github.com/spatie/laravel-query-builder), with exact filters, the same sortable columns and the same pagination. Spatie answers 400 for an unknown filter or sort instead of ignoring it. For partial matches, swap `AllowedFilter::exact` for `AllowedFilter::partial` in the service.

The flag works with every generation mode, and `query_builder: true` can be set globally or per entity in a schema file.

## Pest tests

```bash
php artisan make:fullapi Post --fields="title:string" --pest
```

Generates `it(...)` / `expect(...)` style tests instead of PHPUnit classes, with the same coverage. See [Generated Tests](/guide/testing).

## Interactive wizard

```bash
php artisan make:fullapi --interactive
```

A step-by-step guided setup: entity name, fields one by one (type, nullable, unique, default), relationships, options, and a full preview before generation. Ideal for configuring constraints not available in the `--fields` string syntax.

## Regenerate selected files with `--only=`

To rebuild a `Resource` or a `Test` without touching everything else:

```bash
php artisan make:fullapi Post --only=FeatureTest,UnitTest
```

The fields, relations and options come from the definition recorded when the entity was generated. An entity generated before 4.1 needs its `--fields` once (see [Regenerate specific files](/guide/evolving#regenerate-specific-files)).

When `--only=` is set, the migration, the `apiResource` route and the `DatabaseSeeder` registration are **left untouched**: only the listed artifacts are rewritten. A listed file you edited by hand is kept unless you add `--force` (see [Evolving Entities](/guide/evolving#your-edits-survive-regeneration)).

Available types: `Model`, `Controller`, `Service`, `DTO`, `Request`, `Resource`, `Migration`, `Factory`, `Seeder`, `Policy`, `FeatureTest`, `UnitTest`.

## Deleting an entity

```bash
php artisan delete:fullapi Post
```

After a confirmation, removes all generated files, unregisters the seeder from `DatabaseSeeder.php`, and cleans the entity's routes from `routes/api.php` and `routes/web.php`. Called without an entity name, it deletes every entity defined in `class_data.json`. Add `--force` to skip the question in scripts, or `--dry-run` to list what would be removed without deleting anything.

If older deletions left routes pointing at controllers that no longer exist (the classic `route:list` ReflectionException), purge them:

::: code-group

```bash [Preview]
php artisan api-generator:clean-routes --dry-run
```

```bash [Apply]
php artisan api-generator:clean-routes
```

:::

## All options combined

```bash
php artisan make:fullapi Post --fields="title:string,content:text" --soft-deletes --postman --auth --pest
```

The full flag list lives in the [CLI Reference](/reference/cli).
