PHPackages                             takielias/contract-resolver - 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. takielias/contract-resolver

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

takielias/contract-resolver
===========================

A Laravel package that automatically resolves and binds contracts (interfaces) to their implementations, with powerful code generation commands for repositories and services following the Repository and Service pattern.

0.3(1mo ago)244MITPHPPHP ^8.3CI passing

Since Jul 5Pushed 1mo agoCompare

[ Source](https://github.com/takielias/contract-resolver)[ Packagist](https://packagist.org/packages/takielias/contract-resolver)[ Docs](https://github.com/takielias/contract-resolver)[ RSS](/packages/takielias-contract-resolver/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (14)Versions (5)Used By (0)

Contract Resolver
=================

[](#contract-resolver)

[![Latest Version](https://camo.githubusercontent.com/234889cf7fb139ebc69e24f60620fd744ca6d971ba47e573c4efc25b52a0d1aa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f74616b69656c6961732f636f6e74726163742d7265736f6c7665723f636f6c6f723d626c7565266c6162656c3d72656c65617365267374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/takielias/contract-resolver)[![Stars](https://camo.githubusercontent.com/a7c86fa882959ae85a8752effef37bb0a056d15ff37958123adba4cdc6dca5a4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f74616b69656c6961732f636f6e74726163742d7265736f6c7665723f636f6c6f723d7267622532383036253230313839253230323438253239266c6162656c3d7374617273267374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/takielias/contract-resolver)[![Total Downloads](https://camo.githubusercontent.com/3696d81b2d881d61fa782660a8a61b200e54518516b459467563f600b58e50d7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f74616b69656c6961732f636f6e74726163742d7265736f6c7665722e7376673f636f6c6f723d7267622532383234392532303131352532303232253239267374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/takielias/contract-resolver)[![Issues](https://camo.githubusercontent.com/0359f5b94159ccf2609fb42f06ad07a9b31e42d9a3dc65d34ea25a6dbb9cbcbc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f74616b69656c6961732f636f6e74726163742d7265736f6c7665723f636f6c6f723d726762253238313334253230323339253230313238253239267374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/takielias/contract-resolver)[![Forks](https://camo.githubusercontent.com/dbb8511cb6ac67c87770df44ede85defa90f1b56fb0cff1a39412c38cdc27e7f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f74616b69656c6961732f636f6e74726163742d7265736f6c7665723f636f6c6f723d7267622532383133342532303131352532303232253239267374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/takielias/contract-resolver)[![GitHub Actions Workflow Status](https://camo.githubusercontent.com/4fa6e4e3481d868ad3196ca68640d8b342bedeb9546b7eed518880b2647e6bc5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f74616b69656c6961732f636f6e74726163742d7265736f6c7665722f74657374732e796d6c3f6272616e63683d6d61696e267374796c653d666f722d7468652d6261646765)](https://camo.githubusercontent.com/4fa6e4e3481d868ad3196ca68640d8b342bedeb9546b7eed518880b2647e6bc5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f74616b69656c6961732f636f6e74726163742d7265736f6c7665722f74657374732e796d6c3f6272616e63683d6d61696e267374796c653d666f722d7468652d6261646765)[![Linkedin](https://camo.githubusercontent.com/65e57dee4eb0633fbca0429b13af9bcaa0e812e98f96c849653f970942fc7e9b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f2d4c696e6b6564496e2d626c61636b2e7376673f6c6f676f3d6c696e6b6564696e26636f6c6f723d72676261283233352532303638253230353029267374796c653d666f722d7468652d6261646765)](https://linkedin.com/in/takielias)

A powerful Laravel package that automatically resolves and binds contracts (interfaces) to their implementations, with comprehensive code generation commands for repositories and services following the Repository and Service pattern.

[ ![takielias](https://camo.githubusercontent.com/0cf29a542375e1a46e84d8bf5805a4e5c0a6ee98b6547ccdc0c55eed49d99c69/68747470733a2f2f63646e2e6275796d6561636f666665652e636f6d2f627574746f6e732f76322f64656661756c742d79656c6c6f772e706e67)](https://www.buymeacoffee.com/takielias)

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

[](#-features)

- **🔄 Auto-binding**: Automatically binds interfaces to their implementations
- **🎨 Code Generation**: Generate repositories, services, and their interfaces with artisan commands
- **📁 Convention-based**: Follows Laravel naming conventions and directory structure
- **🔧 Highly Configurable**: Customize paths, namespaces, and binding rules
- **⚡ Performance Optimized**: Efficient file scanning and namespace resolution
- **🧪 Well Tested**: Comprehensive test suite with high code coverage
- **📦 Zero Dependencies**: Only requires core Laravel components

🚀 Installation
--------------

[](#-installation)

You can install the package via composer:

```
composer require takielias/contract-resolver
```

The package will automatically register itself via Laravel's package discovery.

### Publishing Configuration

[](#publishing-configuration)

Optionally, you can publish the config file:

```
php artisan vendor:publish --provider="TakiElias\ContractResolver\ContractResolverServiceProvider" --tag="contract-resolver.config"
```

📖 Usage
-------

[](#-usage)

Available Commands
------------------

[](#available-commands)

CommandDescription`cr:make`Interactive command to create repositories, services, or both`cr:make-repo-interface`Generate repository interface`cr:make-repo`Generate repository implementation`cr:make-service-interface`Generate service interface`cr:make-service`Generate service implementation### Auto-binding Contracts

[](#auto-binding-contracts)

The package automatically scans and binds interfaces to their implementations based on Laravel conventions:

**Directory Structure:**

```
app/
├── Contracts/
│   ├── Repositories/
│   │   ├── UserRepositoryInterface.php
│   │   └── PostRepositoryInterface.php
│   └── Services/
│       ├── UserServiceInterface.php
│       └── PostServiceInterface.php
├── Repositories/
│   ├── UserRepository.php
│   └── PostRepository.php
└── Services/
    ├── UserService.php
    └── PostService.php

```

**Example Interface:**

```
