PHPackages                             manchenkoff/laravel-repositories - 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. [Database &amp; ORM](/categories/database)
4. /
5. manchenkoff/laravel-repositories

ActiveLibrary[Database &amp; ORM](/categories/database)

manchenkoff/laravel-repositories
================================

Repository pattern implementation for your Laravel application

v0.0.9(1mo ago)1199MITPHPPHP ^8.2

Since Sep 24Pushed 1mo ago1 watchersCompare

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

READMEChangelog (9)Dependencies (24)Versions (11)Used By (0)

Laravel Repositories
====================

[](#laravel-repositories)

[![Packagist Version](https://camo.githubusercontent.com/4f2107bd21d6d9d7a1af1eb01130d5a7a3ae0c2b01f7eca8e79042588379f47f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d616e6368656e6b6f66662f6c61726176656c2d7265706f7369746f72696573)](https://camo.githubusercontent.com/4f2107bd21d6d9d7a1af1eb01130d5a7a3ae0c2b01f7eca8e79042588379f47f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d616e6368656e6b6f66662f6c61726176656c2d7265706f7369746f72696573)[![Packagist Downloads](https://camo.githubusercontent.com/b9200c7b07832916311e648a0e317611779601e492800bd9519f83c480aaf873/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d616e6368656e6b6f66662f6c61726176656c2d7265706f7369746f72696573)](https://camo.githubusercontent.com/b9200c7b07832916311e648a0e317611779601e492800bd9519f83c480aaf873/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d616e6368656e6b6f66662f6c61726176656c2d7265706f7369746f72696573)[![Packagist License](https://camo.githubusercontent.com/62dd1185e09af55e447b79e315bbe3fd3bd41891ea9545e9b5cc34b7afeece49/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d616e6368656e6b6f66662f6c61726176656c2d7265706f7369746f72696573)](https://camo.githubusercontent.com/62dd1185e09af55e447b79e315bbe3fd3bd41891ea9545e9b5cc34b7afeece49/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d616e6368656e6b6f66662f6c61726176656c2d7265706f7369746f72696573)[![Packagist Dependency Version](https://camo.githubusercontent.com/fc867554af440a9ec0d0cd0901086651e09cf3b7cc8458db7aa4d0268675a23e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f6d616e6368656e6b6f66662f6c61726176656c2d7265706f7369746f726965732f706870)](https://camo.githubusercontent.com/fc867554af440a9ec0d0cd0901086651e09cf3b7cc8458db7aa4d0268675a23e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f6d616e6368656e6b6f66662f6c61726176656c2d7265706f7369746f726965732f706870)

Package provides a basic implementation of Repository pattern with `artisan` command to generate classes.

Features:

- `Repository` class with basic methods like `all`, `find`, `create`, `update`, `delete`
- Generic type comments to pass `PHPStan` checks
- Artisan `make:repository` command to generate repository class with model and interface

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

[](#installation)

To install this package, you need to install [Composer](https://getcomposer.org/) first, and then run:

```
composer require manchenkoff/laravel-repositories
```

or add this line to `composer.json`:

```
"manchenkoff/laravel-repositories": "*"
```

and run `composer update` in the terminal.

Package should automatically register its service provider in your application, but you can do it manually in `config/app.php`:

```
'providers' => ServiceProvider::defaultProviders()
    ->merge([
        // Package Service Providers
        \Manchenkoff\Laravel\Repositories\ServiceProvider::class,

        // Application Service Providers
        // ...
    ])
    ->toArray(),
```

Usage
-----

[](#usage)

First of all, you need to create a model class for your repository. You can do it manually or use `artisan` command:

```
php artisan make:model Post
```

Then you can create a repository class for your model:

```
# repository name - PostRepository
# model name - Post
php artisan make:repository PostRepository Post
```

This command will create a repository class in `app/Repositories` directory and `PostRepositoryInterface` contract class in `app/Contracts/Repositories`.

Now you can use existing methods in your services or extend with custom functionality:

```
