triquang/laravel-solid-maker

Generate SOLID-based scaffolding (Service, Repository, Tests...) for Laravel — supports both standard and modular architectures.

Installs: 13

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/triquang/laravel-solid-maker

2.1.1 2025-08-20 12:51 UTC

This package is auto-updated.

Last update: 2025-12-20 17:18:35 UTC


README

Latest Version on Packagist Total Downloads License

Laravel Solid Maker is a developer-friendly package for Laravel that allows you to quickly scaffold SOLID-structured boilerplate code across key architectural layers.

It supports both standard Laravel and modular Laravel architectures (e.g., using nwidart/laravel-modules).

✨ What It Generates

Database Layer

  • Model
  • Migration
  • Factory
  • Seeder

Flow Layer

  • Controller
  • Form Request (Store, Update)
  • Resource
  • Policy

Business Logic Layer

  • Service
  • Repository
  • Repository Interface

Testing Layer

  • Unit Test
  • Feature Test

Binding

  • Interface bindings

    • *RepositoryServiceProvider
      • Standard Laravel: Register in bootstrap/providers.php (first-time only, if needed).
      • Modular Laravel: Register in module.json (first-time only, if needed).
  • Auto-registrations

    • *DatabaseSeeder
    • *routes/api.php
    • *Policy
    • *PHPUnit test suites

📦 Installation

This package is intended for development only.
Please install it using the --dev flag:

Install via Composer:

composer require triquang/laravel-solid-maker --dev

The service provider will be automatically registered.

(Optional) Publish the stubs if you want to customize the file templates:

php artisan vendor:publish --tag=solid-stubs

This will publish stub files to:

stubs/vendor/triquang/laravel-solid-maker

🚀 Usage

Generate a full set of SOLID-style files with:

php artisan make:solid-scaffold --model=YourModelName [--module=YourModuleName] [--view]

Options

Option Required Description
--model ✅ Yes Name of the Eloquent model (e.g., Post)
--module ❌ No Module name (for modular Laravel projects)
--view ❌ No Generate web.php routes instead of api.php

Example

php artisan make:solid-scaffold --model=Post --module=Blog

This will generate and register:

  • Database Layer: Model, Migration, Factory, Seeder
  • Request Layer: Store & Update Form Requests
  • Presentation Layer: Controller, Resource, Policy
  • Business Logic: Service, Repository, Interface
  • Testing: Unit Test, Feature Test
  • Bindings & Registrations:
    • RepositoryServiceProvider
    • BlogDatabaseSeeder
    • module.json
    • routes/api.php

📁 Folder Structure

Create Post SOLID scaffold in Modules\Blog

Project
├── phpunit.xml                                             // register if exists
└── Modules
    └── Blog
        ├── app
        │   ├── Http
        │   │   ├── Controllers
        │   │   │   └── PostController.php
        │   │   ├── Requests
        │   │   │   ├── StorePostRequest.php
        │   │   │   └── UpdatePostRequest.php
        │   │   └── Resources
        │   │       └── PostResource.php
        │   ├── Models
        │   │   └── Post.php
        │   ├── Policies
        │   │   └── PostPolicy.php
        │   ├── Providers
        │   │   ├── BlogServiceProvider.php                // register or create
        │   │   └── RepositoryServiceProvider.php          // register or create
        │   ├── Repositories
        │   │   ├── Contracts
        │   │   │   └── PostRepositoryInterface.php
        │   │   └── PostRepository.php
        │   └── Services
        │       └── PostService.php
        ├── database
        │   ├── factories
        │   │   └── PostFactory.php
        │   ├── migrations
        │   │   └── YYYY_mm_dd_His_create_posts_table.php
        │   └── seeders
        │       ├── BlogDatabaseSeeder.php                  // register or create
        │       └── PostSeeder.php
        ├── module.json                                     // register or create
        ├── routes
        │   └── api.php                                     // register or create
        └── tests
            ├── Feature
            │   └── PostTest.php
            └── Unit
                └── PostServiceTest.php

🛠 Customizing the Stubs

Once published, you can edit stub templates at:

stubs/vendor/triquang/laravel-solid-maker

Your future generated files will reflect those customizations.

🧭 Auto-Generated Code Markers

This package adds clear flags in generated code to help developers easily find and review them.

Example

// AUTO-GEN: Placeholder
public function getAll()
{
    return $this->repository->getAll();
}

Available Markers

  • // AUTO-GEN-4-SOLID
  • // AUTO-GEN: Placeholder
  • AUTO-GEN: Placeholder - Incomplete test.

You can quickly search these markers (Ctrl/Cmd+Shift+F) to locate auto-generated code and remove them after review.

✅ Requirements

  • PHP >= 8.0
  • Laravel 11 / 12
  • Composer

📄 License

MIT © Nguyễn Trí Quang

🙌 Contributing

PRs are welcome! Feel free to improve functionality or report issues via GitHub Issues.

📬 Contact