PHPackages                             josesierradev/laravel-service-gateway - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. josesierradev/laravel-service-gateway

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

josesierradev/laravel-service-gateway
=====================================

A Laravel package to generate Service and Gateway classes for clean architecture projects.

2025.04.28(1y ago)143MITPHPPHP &gt;=7.3

Since Apr 26Pushed 1y ago1 watchersCompare

[ Source](https://github.com/JoseSierraDev/laravel-service-gateway)[ Packagist](https://packagist.org/packages/josesierradev/laravel-service-gateway)[ RSS](/packages/josesierradev-laravel-service-gateway/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (3)Used By (0)

laravel-service-gateway
=======================

[](#laravel-service-gateway)

LaravelServiceGateway is a package that simplifies the creation of Service and Gateway layers in your Laravel projects. It provides custom Artisan commands to generate these layers quickly, ensuring a clean architecture for the logic of your application.

Features
--------

[](#features)

- **Create Services**: Generate service classes for handling business logic.
- **Create Gateways**: Generate gateway classes for external API integrations or other external services.
- **Create Models with Service and Gateway**: Automatically generate a model with corresponding service and gateway classes.

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

[](#installation)

To install the package, run the following command:

```
composer require josesierradev/laravel-service-gateway
```

⚙ Usage
-------

[](#-usage)

After installation, you can use the following Artisan commands:

### Create a Service

[](#create-a-service)

To generate a service, use the following command:

```
php artisan make:service {ServiceName}
```

This will create a service class in the app/Services directory.

### Create a Gateway

[](#create-a-gateway)

To generate a gateway, use the following command:

```
php artisan make:gateway {GatewayName}
```

This will create a gateway class in the app/Gateways directory.

### Create a Model, Service, and Gateway

[](#create-a-model-service-and-gateway)

You can use the extended `make:model` command as usual, but now with the following options:

- `--service` or `-S`: Generate a Service class.
- `--gateway` or `-g`: Generate a Gateway class.
- `--sg` or `--gs`: Generate both Service and Gateway classes.

These can be combined with standard model options like:

- `-m`: Migration
- `-c`: Controller
- `-s`: Seeder
- `-f`: Factory

### Example

[](#example)

```
php artisan make:model Product -mcfs -Sg
```

This will create:

- The `Product` model
- A migration file
- A controller
- A factory
- A seeder
- A service class: `App\Services\ProductService`
- A gateway class: `App\Gateways\ProductGateway`

> ⚠ Note: If the model already exists, the service and gateway will not be created.

Validators
==========

[](#validators)

### `make:validator` Command

[](#makevalidator-command)

The `make:validator` command generates a new Validator class, optionally linked to a Laravel Eloquent model for automatic rule generation. You can also choose to generate a Laravel FormRequest class that uses this validator.

Usage
-----

[](#usage)

```
php artisan make:validator UserValidator
```

### With Model-Based Rule Generation

[](#with-model-based-rule-generation)

```
php artisan make:validator UserValidator --model=User
```

This will create a validator using the schema (if available) or model `$fillable` and `$casts` as fallback.

### With FormRequest

[](#with-formrequest)

```
php artisan make:validator UserValidator --formRequest
```

Also generates a `UserValidatorRequest` FormRequest and links its `rules()` method to use the `UserValidator::rules()`.

### With Both

[](#with-both)

```
php artisan make:validator UserValidator --model=User --formRequest
```

Rule Generation Strategy
------------------------

[](#rule-generation-strategy)

1. **Using Schema (default)**: The command attempts to load the table structure from the database using Laravel Schema and Doctrine to infer column types, nullability, foreign keys, and unique constraints.
2. **Fallback to `$fillable`**: If the table does not exist in the schema, it warns the developer and uses the `$fillable` and `$casts` from the model to generate basic rules.

Examples
--------

[](#examples)

```
public static function rules(): array
{
    return [
        'name' => ['required', 'string', 'max:255'],
        'email' => ['required', 'string', 'max:255', 'unique:users,email'],
        'age' => ['nullable', 'integer'],
        'is_active' => ['required', 'boolean'],
        'created_by' => ['exists:users,id']
    ];
}
```

Notes
-----

[](#notes)

- The command supports foreign key validation using the `exists:` rule if the schema is available.
- Supports types: `string`, `integer`, `boolean`, `numeric`, `date`, `array` based on the schema or casts.

Options
-------

[](#options)

OptionShortcutDescription`--model=Model``-m`Generate validation rules based on the model class`--formRequest``-f`Also create a FormRequest class using this validatorOutput
------

[](#output)

The validator will be created in the `App\Validators` namespace unless otherwise configured.

If `--formRequest` is passed, a file will also be created in `App\Http\Requests` and will use the validator rules.

---

Made with ❤️ by [JoseSierraDev](https://github.com/JoseSierraDev)

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance48

Moderate activity, may be stable

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

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

Total

2

Last Release

388d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/058fe4b841ba494d2a08932106a26adbc45ccf58dc9492157e56680348da7863?d=identicon)[JoseSierraDev](/maintainers/JoseSierraDev)

---

Top Contributors

[![JoseSierraDev](https://avatars.githubusercontent.com/u/15071683?v=4)](https://github.com/JoseSierraDev "JoseSierraDev (9 commits)")

### Embed Badge

![Health badge](/badges/josesierradev-laravel-service-gateway/health.svg)

```
[![Health](https://phpackages.com/badges/josesierradev-laravel-service-gateway/health.svg)](https://phpackages.com/packages/josesierradev-laravel-service-gateway)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[orchestra/canvas

Code Generators for Laravel Applications and Packages

20917.2M158](/packages/orchestra-canvas)[illuminate/pipeline

The Illuminate Pipeline package.

9346.6M213](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10532.5M862](/packages/illuminate-pagination)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[spatie/laravel-mix-preload

Add preload and prefetch links based your Mix manifest

169176.0k2](/packages/spatie-laravel-mix-preload)

PHPackages © 2026

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