PHPackages                             charlesmasinde/api-scaffolder - 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. [API Development](/categories/api)
4. /
5. charlesmasinde/api-scaffolder

ActiveLibrary[API Development](/categories/api)

charlesmasinde/api-scaffolder
=============================

Generate full API modules (Controller, Requests, Resource, Policy, Routes) from Eloquent models.

v1.2.3(4mo ago)123MITPHPPHP ^8.2

Since Dec 28Pushed 2w agoCompare

[ Source](https://github.com/WMCharles/api-scaffolder)[ Packagist](https://packagist.org/packages/charlesmasinde/api-scaffolder)[ RSS](/packages/charlesmasinde-api-scaffolder/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (2)Versions (13)Used By (0)

Laravel API Scaffolder
======================

[](#laravel-api-scaffolder)

Generate complete, production-ready API modules from your Eloquent models in seconds.

One command creates a versioned controller (with CRUD + bulk store), form requests with auto-detected validation rules, a resource with smart relationship mapping, a policy, and wired-up routes.

Installation
------------

[](#installation)

```
composer require charlesmasinde/api-scaffolder --dev
```

The service provider is auto-discovered. No manual registration needed.

Quick Start
-----------

[](#quick-start)

```
# Ensure your model and migration exist first
php artisan make:model Tag -m
php artisan migrate

# Scaffold the full API module (interactive prompt)
php artisan make:api-module Tag
```

This generates:

- `app/Http/Controllers/Api/V1/TagController.php` — index, show, store, update, destroy, bulkStore
- `app/Http/Requests/StoreTagRequest.php` — rules parsed from your migration
- `app/Http/Requests/UpdateTagRequest.php` — all fields `sometimes`
- `app/Http/Resources/TagResource.php` — columns + parent names + child collections
- `app/Policies/TagPolicy.php` — standard policy scaffold
- `routes/api.php` — bulk and apiResource routes appended

Usage
-----

[](#usage)

### Generate everything (no prompts)

[](#generate-everything-no-prompts)

```
php artisan make:api-module Tag --all
```

### Generate specific components only

[](#generate-specific-components-only)

```
# Only controller and resource
php artisan make:api-module Tag --only=controller,resource

# Only requests
php artisan make:api-module Tag --only=request

# Multiple --only flags work too
php artisan make:api-module Tag --only=controller --only=request
```

Valid component names: `controller`, `request`, `resource`, `policy`, `routes`

### Interactive mode (default)

[](#interactive-mode-default)

When you run the command without `--all` or `--only`, you get a multi-choice menu:

```
Which components would you like to generate? (comma-separated numbers, or "all")
  [0] All components
  [1] Controller (CRUD + bulk store)
  [2] Form Requests (Store + Update)
  [3] API Resource
  [4] Policy
  [5] Routes (api.php)

```

### Handling existing files

[](#handling-existing-files)

If a file already exists, you'll be prompted:

```
TagController already exists. What would you like to do?
  [0] Overwrite
  [1] Skip

```

To skip all prompts and overwrite everything:

```
php artisan make:api-module Tag --all --force
```

### Specify API version

[](#specify-api-version)

```
php artisan make:api-module Tag V2
```

Configuration
-------------

[](#configuration)

Publish the config to customize defaults:

```
php artisan vendor:publish --tag=api-scaffolder-config
```

This creates `config/api-scaffolder.php` where you can change:

- **middleware** — route middleware (default: `auth:sanctum`)
- **default\_per\_page** — pagination size (default: `100`)
- **skip\_columns** — columns excluded from resources (default: timestamps)
- **auto\_assign\_user\_id** — auto-set `user_id` from auth (default: `true`)
- **unique\_columns** — columns that get `unique` rules on store
- **request\_skip\_columns** — columns excluded from validation rules

Custom Stubs
------------

[](#custom-stubs)

Publish stubs to `stubs/api-scaffolder/` and modify them:

```
php artisan vendor:publish --tag=api-scaffolder-stubs
```

The scaffolder will use your custom stubs over the defaults.

Smart Relationship Detection
----------------------------

[](#smart-relationship-detection)

The resource generator uses return type hints to detect relationships:

```
// In your model — type hints are required
public function user(): BelongsTo      // → 'user_name' => $this->user?->name
public function transactions(): HasMany // → 'transactions' => $this->whenLoaded('transactions')
```

The controller automatically eager-loads all detected relationships.

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 11, 12, or 13
- Models must have return type hints on relationship methods

License
-------

[](#license)

MIT

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance87

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity55

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 ~9 days

Recently: every ~24 days

Total

12

Last Release

135d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/108325038?v=4)[Charles Wafula](/maintainers/WMCharles)[@WMCharles](https://github.com/WMCharles)

---

Top Contributors

[![WMCharles](https://avatars.githubusercontent.com/u/108325038?v=4)](https://github.com/WMCharles "WMCharles (17 commits)")

### Embed Badge

![Health badge](/badges/charlesmasinde-api-scaffolder/health.svg)

```
[![Health](https://phpackages.com/badges/charlesmasinde-api-scaffolder/health.svg)](https://phpackages.com/packages/charlesmasinde-api-scaffolder)
```

###  Alternatives

[statamic/cms

The Statamic CMS Core Package

4.9k3.8M1.2k](/packages/statamic-cms)[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

137236.2k8](/packages/statamic-rad-pack-runway)[duncanmcclean/statamic-cargo

Comprehensive e-commerce addon for Statamic. Build bespoke e-commerce sites without the complexity.

3622.8k](/packages/duncanmcclean-statamic-cargo)[scriptdevelop/whatsapp-manager

Paquete para manejo de WhatsApp Business API en Laravel

793.9k](/packages/scriptdevelop-whatsapp-manager)

PHPackages © 2026

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