PHPackages                             l0n3ly/laravel-repository-with-service - 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. l0n3ly/laravel-repository-with-service

ActiveLibrary[Framework](/categories/framework)

l0n3ly/laravel-repository-with-service
======================================

Repository and service pattern package for Laravel

v2.0.1(4w ago)033—10%MITPHPPHP ^8.2CI failing

Since Mar 30Pushed 3w agoCompare

[ Source](https://github.com/idehen-divine/laravel-repository-with-service)[ Packagist](https://packagist.org/packages/l0n3ly/laravel-repository-with-service)[ Docs](https://github.com/l0n3ly/laravel-repository-with-service.git)[ RSS](/packages/l0n3ly-laravel-repository-with-service/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (7)Dependencies (33)Versions (9)Used By (0)

Laravel Repository With Service
===============================

[](#laravel-repository-with-service)

[![Latest Version](https://camo.githubusercontent.com/e1013f312b7656e3c22595536389c4fd2b68412f4d716033df386f49c2763772/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c306e336c792f6c61726176656c2d7265706f7369746f72792d776974682d736572766963652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/l0n3ly/laravel-repository-with-service)[![Total Downloads](https://camo.githubusercontent.com/e1d8a81ce63180b95d3fa632bb123f7c781ef97b4af8d45ade99595d3a062c83/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c306e336c792f6c61726176656c2d7265706f7369746f72792d776974682d736572766963652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/l0n3ly/laravel-repository-with-service)[![License](https://camo.githubusercontent.com/c19d2d37d37339d31338e13e3912b9ae07630d78fe966e112025355e0626964c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6c306e336c792f6c61726176656c2d7265706f7369746f72792d776974682d736572766963652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/l0n3ly/laravel-repository-with-service)[![Laravel Boost Compatible](https://camo.githubusercontent.com/915bb175cd1f3f083b8de5f6777d123a6c30a15972e5647c609bd61356c38471/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c253230426f6f73742d436f6d70617469626c652d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](./BOOST.md)

A Laravel package that scaffolds the repository and service pattern — generates repository and service classes with interfaces, and automatically binds them to their implementations via the container.

✨ Features
----------

[](#-features)

- 🏗️ **Artisan Scaffolding** - Generate repositories and services with `make:repository` and `make:service`
- 🔗 **Auto Binding** - Automatically binds interfaces to implementations via the service container
- 📁 **Subdirectory Support** - Organize classes in nested directories (e.g., `Admin/UserRepository`)
- 🔄 **Paired Generation** - Generate a repository and service together with a single command
- 📋 **Interface-First** - Always generates a contract interface alongside each implementation
- 🎨 **Multiple Templates** - Choose between API service template or blank template
- 🤖 **Boost Compatible** - Full support for Laravel Boost AI-powered workflows and Copilot skills

📋 Requirements
--------------

[](#-requirements)

- PHP ^8.2
- Laravel 11, 12, or 13

📦 Installation
--------------

[](#-installation)

Install the latest 1.x release:

```
composer require l0n3ly/laravel-repository-with-service
```

Publish the config file:

```
php artisan vendor:publish --tag=repository-with-service-config
```

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

[](#quick-start)

### Fastest Start: Generate Everything at Once

[](#fastest-start-generate-everything-at-once)

Scaffold a complete feature with one command:

```
php artisan make:model User --all
```

This creates everything — model, migration, factory, seeder, controller, repository, and service.

### Generate a Repository

[](#generate-a-repository)

```
# Basic repository
php artisan make:repository User

# Repository with paired service
php artisan make:repository User --service

# Repository with API-style service
php artisan make:repository User --service --api

# Repository in subdirectory
php artisan make:repository Admin/User --service
```

### Generate a Service

[](#generate-a-service)

```
# Basic service
php artisan make:service UserService

# API service with response helpers
php artisan make:service UserService --api

# Service with paired repository
php artisan make:service UserService --repository

# Minimal service
php artisan make:service UserService --blank
```

### Generate from a Model

[](#generate-from-a-model)

```
# Model with service and repository
php artisan make:model Product --service --repository

# Model with everything (fastest)
php artisan make:model Order --all
```

### Use in Your Code

[](#use-in-your-code)

Services and repositories are automatically bound to the container:

```
class UserController extends Controller
{
    public function __construct(
        protected UserRepository $repository,
        protected UserService $service
    ) {}

    public function index()
    {
        return $this->service->getActiveUsers();
    }
}
```

📖 Documentation
---------------

[](#-documentation)

Comprehensive documentation is available:

DocumentPurpose[Full Guide](./docs/README.md)Installation, quick start, and all commands[API Reference](./docs/API.md)Core interfaces and configuration[Troubleshooting](./docs/TROUBLESHOOTING.md)Common issues and solutions[Examples](./docs/EXAMPLES.md)Real-world usage examples[Contributing](./CONTRIBUTING.md)Contribution guidelines[Laravel Boost Integration](./BOOST.md)Using with AI-powered Boost workflows🤖 Laravel Boost Support
-----------------------

[](#-laravel-boost-support)

This package is fully integrated with **Laravel Boost** and provides three AI skills to enhance your development workflow:

### Three Essential Skills

[](#three-essential-skills)

- **Repository Generator** - Generate repositories with best practices
- **Service Generator** - Generate services with business logic
- **Service Binding** - Understand dependency injection and binding patterns

These skills are located in `resources/boost/skills/` and are discovered by running:

```
php artisan boost:install --discover
```

Select the desired skills during installation, and they'll be available to your AI agent.

### AI-Powered Workflows

[](#ai-powered-workflows)

Get intelligent suggestions for:

- Generating complete feature modules
- Creating repository hierarchies
- Setting up service structures
- Testing patterns and mocking

### Example Boost Usage

[](#example-boost-usage)

```
User: "Generate a complete blog module with posts, comments, and categories"

Boost activates the skills and suggests:
✓ PostRepository with PostService (API template)
✓ CommentRepository with CommentService
✓ CategoryRepository with CategoryService
✓ BlogManager service orchestrating operations

```

### Getting Started with Boost

[](#getting-started-with-boost)

1. Install Laravel Boost in your Laravel project
2. Run `php artisan boost:install --discover`
3. Select this package's skills when prompted
4. Ask your AI agent to generate repositories, services, or help with architecture

See [BOOST.md](./BOOST.md) for detailed integration guide.

🎯 Common Patterns
-----------------

[](#-common-patterns)

### Blog Application

[](#blog-application)

```
php artisan make:repository Post --service --api
php artisan make:repository Category --service
php artisan make:repository Post/Comment --service
```

### E-Commerce

[](#e-commerce)

```
php artisan make:repository Product --service --api
php artisan make:repository Order --service --api
php artisan make:service Shop/Checkout --api
php artisan make:service Shop/Inventory --api
```

### SaaS with Multi-Tenancy

[](#saas-with-multi-tenancy)

```
php artisan make:repository Tenant --service --api
php artisan make:repository User --service --api
php artisan make:repository Subscription --service --api
```

See [EXAMPLES.md](./EXAMPLES.md) for complete real-world examples.

🔧 Configuration
---------------

[](#-configuration)

Edit `config/service-repository.php` to customize:

```
return [
    'repository_directory' => 'app/Repositories',
    'repository_namespace' => 'App\Repositories',
    'service_directory' => 'app/Services',
    'service_namespace' => 'App\Services',
    // ... naming conventions
];
```

Override Binding Example
------------------------

[](#override-binding-example)

Decorate or replace a bound implementation in your service provider:

```
$this->app->extend(UserRepository::class, function ($service, $app) {
    return new CachedUserRepository($service);
});
```

Service API Template
--------------------

[](#service-api-template)

The `--api` flag generates services with response helpers:

```
class UserServiceImplement implements UserService
{
    use ResultService;

    public function create(array $data): array
    {
        try {
            $user = $this->repository->create($data);
            return $this->success($user, 'User created');
        } catch (Exception $e) {
            return $this->error($e->getMessage());
        }
    }
}
```

🚀 Performance Tips
------------------

[](#-performance-tips)

1. **Use Caching** - Wrap repositories with caching decorators
2. **Eager Loading** - Use Eloquent's `with()` in repositories
3. **Singleton Services** - For stateless services, bind as singleton
4. **Optimize Queries** - Focus repository methods on specific queries

🧪 Testing
---------

[](#-testing)

Mock repositories in tests:

```
public function test_service_logic()
{
    $repository = Mockery::mock(UserRepository::class);
    $repository->shouldReceive('find')->with(1)->andReturn(['id' => 1]);

    $this->app->bind(UserRepository::class, fn() => $repository);

    $service = app(UserService::class);
    $result = $service->getUser(1);

    $this->assertEquals(1, $result['id']);
}
```

📚 Real-World Examples
---------------------

[](#-real-world-examples)

Check [EXAMPLES.md](./EXAMPLES.md) for complete implementations:

- Blog with posts, comments, and categories
- E-commerce checkout process
- Multi-tenant SaaS structure
- Admin dashboards
- Testing patterns

🤝 Contributing
--------------

[](#-contributing)

Contributions are welcome! See [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines.

📄 License
---------

[](#-license)

The MIT License (MIT). Please see [LICENSE.md](LICENSE.md) for more information.

Support
-------

[](#support)

- 📖 **Documentation**: See `docs/` directory
- 🐛 **Issues**: Report on GitHub
- 💬 **Discussions**: Ask questions on GitHub Discussions
- 🔧 **Help**: Check [Troubleshooting Guide](./docs/TROUBLESHOOTING.md)

Project guide:

- [V1 Docs](https://l0n3ly.github.io/laravel-service-repository-pattern-guide/)

Changelog
---------

[](#changelog)

See [CHANGELOG](CHANGELOG.md) for release notes.

License
-------

[](#license)

MIT. See [LICENSE.md](LICENSE.md).

###  Health Score

43

—

FairBetter than 90% of packages

Maintenance94

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity52

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

Total

7

Last Release

29d ago

Major Versions

v1.2.1 → v2.0.02026-04-18

### Community

Maintainers

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

---

Top Contributors

[![idehen-divine](https://avatars.githubusercontent.com/u/100498590?v=4)](https://github.com/idehen-divine "idehen-divine (49 commits)")

---

Tags

laravellaravel-repositorylaravel-repository-service

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/l0n3ly-laravel-repository-with-service/health.svg)

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

###  Alternatives

[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.3M42](/packages/spatie-laravel-pdf)[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.1k9.9M91](/packages/dedoc-scramble)[spatie/laravel-health

Monitor the health of a Laravel application

87411.3M154](/packages/spatie-laravel-health)[lunarstorm/laravel-ddd

A Laravel toolkit for Domain Driven Design patterns

18676.4k](/packages/lunarstorm-laravel-ddd)[stephenjude/filament-jetstream

A Laravel starter kit built with Filament inspired by Jetstream.

17758.9k2](/packages/stephenjude-filament-jetstream)[spatie/laravel-passkeys

Use passkeys in your Laravel app

471755.5k32](/packages/spatie-laravel-passkeys)

PHPackages © 2026

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