PHPackages                             zobirofkir/laravel-service-generator - 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. zobirofkir/laravel-service-generator

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

zobirofkir/laravel-service-generator
====================================

Laravel service generator command

v1.0.0(1mo ago)07↓100%MITPHPPHP ^8.1

Since Apr 16Pushed 1mo agoCompare

[ Source](https://github.com/zobirofkir/laravel-service-generator)[ Packagist](https://packagist.org/packages/zobirofkir/laravel-service-generator)[ RSS](/packages/zobirofkir-laravel-service-generator/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

Laravel Service Generator
=========================

[](#laravel-service-generator)

[![Latest Version on Packagist](https://camo.githubusercontent.com/ddf0890614f90dd2a689f123f0201afda7fb5dd0266e84e1b71822f58bb856b2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7a6f6269726f666b69722f6c61726176656c2d736572766963652d67656e657261746f722e737667)](https://packagist.org/packages/zobirofkir/laravel-service-generator)[![Total Downloads](https://camo.githubusercontent.com/5821d4c18c76eb98d616508cfb664655adc254782c1766de07ffba91a5760719/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7a6f6269726f666b69722f6c61726176656c2d736572766963652d67656e657261746f722e737667)](https://packagist.org/packages/zobirofkir/laravel-service-generator)[![License](https://camo.githubusercontent.com/8c9f2e4a88aab7ea4b5b27eef936ebbdd77f6e8c53b00fbe971bfb488d2178ac/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7a6f6269726f666b69722f6c61726176656c2d736572766963652d67656e657261746f722e737667)](https://packagist.org/packages/zobirofkir/laravel-service-generator)[![PHP Version Require](https://camo.githubusercontent.com/9d975d382d49b8b6d0b2f40afca679bbb38182fe3ba80c487d8057e879ed83e2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7a6f6269726f666b69722f6c61726176656c2d736572766963652d67656e657261746f72)](https://packagist.org/packages/zobirofkir/laravel-service-generator)[![Laravel Version](https://camo.githubusercontent.com/ac0a000bd94d737f4360109a28166dd6e0b6628d8afaf7d2bc7827b48a3f37e7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d392e7825453225383025393331332e782d464632443230)](https://laravel.com)

One-command generator for Laravel service architecture — creates Service classes, Contracts (interfaces), Facades, and Service Providers following SOLID principles and Laravel conventions.

Table of contents
-----------------

[](#table-of-contents)

- Features
- Requirements
- Installation
- Usage
- Generated structure
- Architecture &amp; patterns
- Examples
- Configuration
- Troubleshooting
- Contributing
- Changelog
- Security
- License
- Author
- Acknowledgments

What it does in 5 seconds
-------------------------

[](#what-it-does-in-5-seconds)

Generates a Service class, its Contract (interface), a Facade and a Service Provider with one artisan command, wiring them for use in your Laravel app.

Features
--------

[](#features)

- One-command scaffold: Service, Contract, Facade, Provider
- Encourages SOLID design and testable code
- PSR-4 compatible and follows Laravel conventions
- Minimal setup with optional customization points

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

[](#requirements)

- PHP: 8.1+
- Laravel: 9.x — 13.x (tested)
- illuminate/support: compatible with Laravel 9 — 13

Note: These constraints reflect the versions this package is tested against. If you need support for other Laravel versions, please open an issue or PR.

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

[](#installation)

1. Install via Composer (recommended):

```
composer require zobirofkir/laravel-service-generator
```

2. Service provider

Laravel supports package auto-discovery. Manual registration is not required for recent Laravel versions. To register manually add the provider to `config/app.php`:

```
'providers' => [
    Zobirofkir\\ServiceGenerator\\ServiceGeneratorServiceProvider::class,
];
```

3. Generate a service

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

Examples:

```
# Generate a User service
php artisan make:service User

# Generate a Payment service
php artisan make:service Payment
```

What the command does

- Creates directories (if missing):
    - `app/Services/Services`
    - `app/Services/Constructors`
    - `app/Services/Facades`
    - `app/Providers`
- Generates four files for the given name: Service implementation, Contract (interface), Facade and Service Provider.
- Prints a success message when finished.

Generated structure
-------------------

[](#generated-structure)

After running `php artisan make:service User` the package creates:

```
app/
├── Services/
│   ├── Services/UserService.php
│   ├── Constructors/UserConstructor.php
│   └── Facades/UserFacade.php
└── Providers/UserServiceProvider.php

```

Example file snippets (simplified):

```
// app/Services/Services/UserService.php
namespace App\\Services\\Services;

use App\\Services\\Constructors\\UserConstructor;

class UserService implements UserConstructor
{
    // implementation
}
```

```
// app/Services/Constructors/UserConstructor.php
namespace App\\Services\\Constructors;

interface UserConstructor
{
    // contract methods
}
```

```
// app/Services/Facades/UserFacade.php
namespace App\\Services\\Facades;

use Illuminate\\Support\\Facades\\Facade;

class UserFacade extends Facade
{
    protected static function getFacadeAccessor(): string
    {
        return 'UserService';
    }
}
```

The generated `UserServiceProvider` binds the contract to the implementation and registers a singleton alias for the facade accessor.

Architecture &amp; patterns
---------------------------

[](#architecture--patterns)

The package scaffolds a small, opinionated layered architecture that helps keep your application maintainable and testable.

Typical flow:

Controller → Facade → Contract (interface) → Service implementation → Database / external APIs

Benefits:

- Loose coupling: controllers depend on interfaces, not concrete implementations.
- Testability: services and facades are easy to mock.
- Flexibility: swap implementations without changing consumers.

Design patterns used (brief):

- Facade — provides a simple static interface for services.
- Dependency Inversion / Contract pattern — services implement interfaces used by controllers.
- Service Provider — registers bindings in the container.
- Strategy (optional) — swap service implementations for different behaviors.

Examples
--------

[](#examples)

Below are condensed examples to help you get started quickly.

Example: User service (contract + implementation + controller usage)

```
// app/Services/Constructors/UserConstructor.php
namespace App\\Services\\Constructors;

use App\\Models\\User;
use Illuminate\\Database\\Eloquent\\Collection;

interface UserConstructor
{
    public function getAllUsers(): Collection;
    public function createUser(array $data): User;
    public function updateUser(int $id, array $data): User;
    public function deleteUser(int $id): bool;
    public function findByEmail(string $email): ?User;
}
```

```
// app/Services/Services/UserService.php
namespace App\\Services\\Services;

use App\\Models\\User;
use App\\Services\\Constructors\\UserConstructor;
use Illuminate\\Database\\Eloquent\\Collection;
use Illuminate\\Support\\Facades\\Hash;

class UserService implements UserConstructor
{
    public function getAllUsers(): Collection
    {
        return User::all();
    }

    public function createUser(array $data): User
    {
        $data['password'] = Hash::make($data['password']);
        return User::create($data);
    }

    public function updateUser(int $id, array $data): User
    {
        $user = User::findOrFail($id);
        if (isset($data['password'])) {
            $data['password'] = Hash::make($data['password']);
        }
        $user->update($data);
        return $user->fresh();
    }

    public function deleteUser(int $id): bool
    {
        return User::findOrFail($id)->delete();
    }

    public function findByEmail(string $email): ?User
    {
        return User::where('email', $email)->first();
    }
}
```

```
// app/Http/Controllers/UserController.php
namespace App\\Http\\Controllers;

use App\\Services\\Facades\\UserFacade;
use App\\Http\\Requests\\UserRequest;

class UserController extends Controller
{
    public function index()
    {
        return response()->json(UserFacade::getAllUsers());
    }

    public function store(UserRequest $request)
    {
        return response()->json(UserFacade::createUser($request->validated()), 201);
    }

    public function update(UserRequest $request, int $id)
    {
        return response()->json(UserFacade::updateUser($id, $request->validated()));
    }

    public function destroy(int $id)
    {
        UserFacade::deleteUser($id);
        return response()->json(null, 204);
    }
}
```

Other examples (payment, email) follow the same pattern: define the contract under `app/Services/Constructors`, implement it in `app/Services/Services`, and optionally add a facade and provider.

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

[](#configuration)

The package works out of the box and requires no configuration. Future releases may provide a publishable config (`php artisan vendor:publish`) to customize paths and namespaces.

If you need custom namespaces, extend the `MakeServiceCommand` and override path helpers to point to your preferred directories.

Troubleshooting
---------------

[](#troubleshooting)

- Class not found after generation: run `composer dump-autoload`.
- Facade not resolving: either register an alias in `config/app.php` or ensure the provider is registered.
- Provider not registered: add the generated provider to `config/app.php` providers array.
- Permission errors creating directories: adjust filesystem permissions (for example `chmod -R 775 app/Services`).

Contributing
------------

[](#contributing)

Contributions, bug reports and PRs are welcome. Please:

1. Fork the repository
2. Create a feature branch (git checkout -b feature/awesome)
3. Commit and push your changes
4. Open a pull request with a clear description

Local development

```
git clone https://github.com/zobirofkir/laravel-service-generator.git
cd laravel-service-generator
composer install
```

Changelog
---------

[](#changelog)

See `CHANGELOG.md` for a full history. Notable items:

- v1.0.0 — Initial release: service, contract, facade and provider generation; support for Laravel 9.x–13.x.

Security
--------

[](#security)

If you discover a security issue, please email Add your email here instead of opening a public issue.

License
-------

[](#license)

This package is open-sourced under the MIT license. See the `LICENSE` file for details.

Author
------

[](#author)

Zobir Ofkir — GitHub: @zobirofkir

Acknowledgments
---------------

[](#acknowledgments)

- Laravel community
- Project contributors and users

Built with ❤️ for the Laravel community

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance89

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity42

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

Unknown

Total

1

Last Release

54d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0cb814cf463265f803e42466992da9f278ddbc4538e2c3450978e957f10dcc03?d=identicon)[zobirofkir](/maintainers/zobirofkir)

---

Top Contributors

[![zobirofkir](https://avatars.githubusercontent.com/u/135469129?v=4)](https://github.com/zobirofkir "zobirofkir (5 commits)")

### Embed Badge

![Health badge](/badges/zobirofkir-laravel-service-generator/health.svg)

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3325.1M337](/packages/psalm-plugin-laravel)[renatomarinho/laravel-page-speed

Laravel Page Speed

2.5k1.7M11](/packages/renatomarinho-laravel-page-speed)[illuminate/pipeline

The Illuminate Pipeline package.

9348.3M264](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10533.5M984](/packages/illuminate-pagination)[illuminate/redis

The Illuminate Redis package.

8314.4M356](/packages/illuminate-redis)[spatie/laravel-export

Create a static site bundle from a Laravel app

670139.5k6](/packages/spatie-laravel-export)

PHPackages © 2026

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