🔧 AI Nachrichten Even the King of England has his hesitations about AI(17.09.2026 um 19:26 Uhr)
📰 IT Security Nachrichten[Virtual Event] Cybersecurity Outlook 2027(03.12.2026 um 17:00 Uhr)
⚠️ Malware / Trojaner / VirenBrevo supply-chain attack injected ClickFix scripts on customer sites(17.09.2026 um 19:11 Uhr)
📰 IT Security NachrichtenRabattprogramm "PayPal+" startet: Wie viel sparen Kunden tatsächlich?(17.09.2026 um 19:26 Uhr)
📰 IT Security NachrichtenpearOS is the MacOS of Linux, and the latest version is better than ever(17.09.2026 um 19:30 Uhr)
📰 IT NachrichtenWill Apple enter the server business?(17.09.2026 um 16:09 Uhr)
🔧 AI Nachrichten Even the King of England has his hesitations about AI(17.09.2026 um 19:26 Uhr)
📰 IT Security Nachrichten[Virtual Event] Cybersecurity Outlook 2027(03.12.2026 um 17:00 Uhr)
⚠️ Malware / Trojaner / VirenBrevo supply-chain attack injected ClickFix scripts on customer sites(17.09.2026 um 19:11 Uhr)
📰 IT Security NachrichtenRabattprogramm "PayPal+" startet: Wie viel sparen Kunden tatsächlich?(17.09.2026 um 19:26 Uhr)
📰 IT Security NachrichtenpearOS is the MacOS of Linux, and the latest version is better than ever(17.09.2026 um 19:30 Uhr)
📰 IT NachrichtenWill Apple enter the server business?(17.09.2026 um 16:09 Uhr)
🔧 Programmierung 🕛 vor 1 Monat 5 Min Lesezeit
0

A complete Laravel API with clean architecture in 30 seconds, tests included

↗ Quelle (dev.to)
🗣️ Stimme:
📑 Inhaltsübersicht

I counted the files I create every time I add a resource to a Laravel API. Model, migration, controller, a form request, a resource, a factory, a seeder, a policy. If the project cares about architecture, add a DTO and a service class. Then the tests.



Twelve files before the first line of actual business logic. I got tired of typing them, so I wrote a generator. It's MIT, I maintain it solo, and v3.6 shipped this week.






One command






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

php artisan make:fullapi Post --fields="title:string,content:text,status:enum(draft,published),published_at:datetime"






Output:




CODE
app/
├── DTO/PostDTO.php
├── Enums/Status.php
├── Http/
│ ├── Controllers/PostController.php
│ ├── Requests/PostRequest.php
│ └── Resources/PostResource.php
├── Models/Post.php
├── Policies/PostPolicy.php
└── Services/PostService.php
database/
├── factories/PostFactory.php
├── migrations/xxxx_create_posts_table.php
└── seeders/PostSeeder.php
tests/
├── Feature/PostControllerTest.php
└── Unit/PostServiceTest.php
routes/api.php ← apiResource registered






[GIF demo.gif (voir fichier 12) : vraie exécution en terminal, pas Claude Design]






The VS Code extension: same engine, no terminal needed



[VISUEL 11 (fichier 13) : VRAI screenshot de l'extension VS Code, habillé ensuite dans Claude Design]



If you'd rather click than type, the free






The part I actually care about: the architecture



Plenty of tools can spit out a model and a migration. What I wanted was the layering I end up building by hand on every serious project. The generated controller is thin:




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

return new PostResource($post);
}






Validation lives in the form request, business logic in PostService, and data crosses layers as a typed readonly PostDTO. When the project grows, the place where new logic should go already exists. That's the whole point.






Models your IDE can read



Each generated model comes with a real PHPDoc block:




CODE
/**
* @property int $id
* @property string $title
* @property string $content
* @property Status $status
* @property \Illuminate\Support\Carbon|null $published_at
* @property-read \Illuminate\Database\Eloquent\Collection<int, Comment> $comments
*/

class Post extends Model






So $post->title autocompletes in VS Code and PhpStorm without installing ide-helper. The generator already knows every field and relation at generation time; writing the docblock costs it nothing.






What enum(draft,published) produced



That one field definition created five coherent pieces:





  • App\Enums\Status, a native backed enum

  • the cast on the model


  • Rule::enum(Status::class) in both form requests


  • fake()->randomElement(Status::cases()) in the factory


  • $table->enum('status', [...]) in the migration



Before v3.6 the package just mapped enums to strings. Wiring the whole chain took longer than I expected, mostly because of the factory.






The tests are written, not scaffolded



This was my line in the sand. Most generators leave you empty test classes. Here php artisan test is green right after generation: index, store, validation errors, update, delete are all covered with real assertions.




CODE
it('creates a post', function () {
$payload = Post::factory()->raw();

$this->postJson('/api/posts', $payload)
->assertCreated();

$this->assertDatabaseHas('posts', ['title' => $payload['title']]);
});






That's the Pest style, from the --pest flag. Without it you get PHPUnit classes with the same coverage.






Docs, Postman, auth



--postman writes a ready-to-import collection at the project root. The controllers are written so

  • GitHub:



  • If you try it and something breaks, open an issue. Schema edge cases reported by users have driven most of the recent releases, and I'd rather hear about yours than guess.

    Vollständiger Original-Artikel
    Den kompletten Beitrag mit allen Details direkt auf dev.to lesen.
    ↗ Original-Artikel auf dev.to lesen
    Wie bewertest du diesen Beitrag?
    1 Klick Feedback
    Teilen mit Netzwerk & Team:

    Community-Analysen & Experten-Meinungen 0

    Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
    Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
    Community Pulse: Relevanz-Einschätzung
    1 Klick Experten-Votum
    🔴 Akute Relevanz 0%
    🟡 In Evaluierung 0%
    🟢 Keine Auswirkung 0%
    Spannende Innovation 0%
    Verwandte Story-Cluster & Quellen (Vektor-KI)
    Port 8095 Engine
    1 Quelle
    Projects are now a conversation with Claude
    1 Quelle
    Microsoft Brings Windows 11 Auto SR to Intel Core Ultra Series 3-Based PCs
    1 Quelle
    Affinity Ships a Major Update With Over 60 New Features
    Ähnliche Beiträge
    🔍 Verwandte News

    Auch interessante Nachrichten A complete Laravel API with clean architecture in 30 seconds, tests included

    Thematisch verwandte Begriffe: complete, Laravel, with, clean · 6 Treffer

    Laden...

    Videos werden geladen ...

    Laden...

    Beiträge werden geladen ...

    Laden...

    Videos werden geladen ...

    Laden...

    Beiträge werden geladen ...

    Laden...

    Videos werden geladen ...

    Laden...

    Beiträge werden geladen ...

    Laden...

    Videos werden geladen ...

    Laden...

    Beiträge werden geladen ...

    Laden...

    Videos werden geladen ...