Back to the portfolio

Case study · Open-source package

laravel-make-pattern: a Laravel CRUD scaffold that works the moment it's generated

laravel-make-pattern is an open-source Laravel package (MIT licence) that I created and published on Packagist in August 2026. One command, php artisan make:pattern Post, generates every layer of a resource, already wired together, with a test that passes straight away.

Role
Author and maintainer
First release
August 2026 (v0.1.0)
Compatibility
PHP 8.2+, Laravel 11, 12 and 13
Licence
MIT

The problem

Writing the same repository / service / controller boilerplate for every resource gets old fast, and copy-pasting an existing module makes resources drift apart.

Existing generators are either too minimal (model and migration) or hard-code an architecture you may not use. Worse, many produce code that doesn't run: a PostService that type-hints PostRepositoryInterface is useless if nothing binds the interface in the container. The first request throws a BindingResolutionException.

What the package does

For a given resource, the command generates:

  • Model, migration and factory
  • Repository and its interface, with the container binding
  • Service and controller
  • Form Requests and an API Resource
  • A policy, registered automatically
  • A route and a Feature test that passes as soon as it's generated

Design choices

Two principles drive the package. First, the generated code must run: the package maintains the repository binding, the policy registration and the route itself. Second, every layer is config-driven: disable a layer, override any stub or point it at a different namespace. The generator adapts to the project's conventions, not the other way round.

It also offers a Domain-Driven Design mode, a custom root namespace, an --only option to generate selected layers, and a generation history with undo and backups.

A detail that matters: routes/api.php

On Laravel 11 and later, routes/api.php only exists after php artisan install:api, and that command silently refuses to wire the file if it already exists. So the generator never creates the file itself: it asks you to run install:api, skips route registration and generates everything else. Edge cases like this are covered by the package's test suite.

Used in production

The package generated every resource in the backend of Kivo, my production app at kivo-africa.com. That is how the whole API, built in five weeks, kept a consistent Controller → Service → Repository architecture.

Links