PHPackages                             henrygodev/laranest - 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. [Framework](/categories/framework)
4. /
5. henrygodev/laranest

ActiveLibrary[Framework](/categories/framework)

henrygodev/laranest
===================

Laravel module scaffolding package

v1.1.0(today)00MITPHPPHP ^7.4|^8.0

Since Jun 12Pushed todayCompare

[ Source](https://github.com/henrygodev/laranest)[ Packagist](https://packagist.org/packages/henrygodev/laranest)[ RSS](/packages/henrygodev-laranest/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (4)Versions (3)Used By (0)

Laranest - Laravel with modules
===============================

[](#laranest---laravel-with-modules)

A simple scaffolding package inspired by NestJs architecture. Each module encapsulates its own controller, requests, and model - keeping your application organized and scalable.

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

[](#requirements)

- PHP ^7.4 | ^8.0
- Laravel ^8.0 | ^9.0 | ^10.0 | ^11.0 | ^12.0

Install
=======

[](#install)

To install via Composer, run

```
composer require henrygodev/laravelnest
```

The package is auto-discovery by Laravel - no need to register the service provider manually.

Usage
-----

[](#usage)

### Basic module

[](#basic-module)

```
php artisan make:module Product
```

Generates:

```
app/
└── Modules/
    └── Products/
        ├── Controllers/
        │   └── ProductController.php
        ├── Models/
        │   └── Product.php
        └── Requests/
            ├── StoreProductRequest.php
            └── UpdateProductRequest.php

```

### API module

[](#api-module)

Generate a controller with JSON response and full CRUD methods.

```
php artisan make:module Product --api
```

```
class ProductController extends Controller
{
    public function index(): JsonResponse { ... }
    public function store(StoreProductRequest $request): JsonResponse { ... }
    public function show(Product $product): JsonResponse { ... }
    public function update(UpdateProductRequest $request, Product $product): JsonResponse { ... }
    public function destroy(Product $product): JsonResponse { ... }
}
```

### Resource module

[](#resource-module)

Generate a controller with view returns and redirects, following Laravel's resource convention.

```
php artisan make:module Product --resource
```

```
class ProductController extends Controller
{
    public function index() { ... }
    public function create() { ... }
    public function store(StoreProductRequest $request) { ... }
    public function show(Product $model) { ... }
    public function edit(Product $model) { ... }
    public function update(UpdateProductRequest $request, Product $model) { ... }
    public function destroy(Product $model) { ... }
}
```

### Migrations

[](#migrations)

Generate a migration file in `database/migrations`

```
php artisan make:module Product --migration
```

Generates:

```
database/
    └── migrations/
        └── 2025_01_01_000000_create_products_table.php

```

Also combinable with other flags:

```
php artisan make:module Product --api --migration
```

### Multi-word names

[](#multi-word-names)

The module name is automatically converted to StudlyCase and pluralized.

```
php artisan make:module ProductCategory
# or
php artisan make:module product_category
```

Both generate:

```
app/Modules/ProductCategories/

```

Customizing stubs
-----------------

[](#customizing-stubs)

Publish the defaults stubs to your project:

```
php artisan vendor:publish --tag=larvel-module-stubs
```

This copies all stubs to:

```
stubs/
└── laravel-module/
    ├── controller.stub
    ├── controller-api-imports.stub
    ├── controller-api-methods.stub
    ├── controller-resource-methods.stub
    ├── model.stub
    ├── store-request.stub
    └── update-request.stub

```

Edit any stub to match your project conventions. Published stubs take priority over the package defaults - you only need to publish the ones you want to customize.

**Example:** adding `SoftDelete` to every generated model:

```
// stubs/laravel-module/model.stub
