Download the PHP package takielias/contract-resolver without Composer
On this page you can find all versions of the php package takielias/contract-resolver. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download takielias/contract-resolver
More information about takielias/contract-resolver
Files in takielias/contract-resolver
Package contract-resolver
Short Description 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.
License MIT
Homepage https://github.com/takielias/contract-resolver
Informations about the package contract-resolver
Contract Resolver
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.
โจ 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
You can install the package via composer:
The package will automatically register itself via Laravel's package discovery.
Publishing Configuration
Optionally, you can publish the config file:
๐ Usage
Available Commands
Command | Description |
---|---|
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
The package automatically scans and binds interfaces to their implementations based on Laravel conventions:
Directory Structure:
Example Interface:
Example Implementation:
Using in Controllers:
Code Generation Commands
The package provides powerful artisan commands to generate boilerplate code:
Generate Everything
This interactive command will prompt you to:
- Choose what to create (Service, Repository, or All)
- Enter the name (e.g., "Product")
Generate Repository with Interface
Generated Interface (app/Contracts/Repositories/ProductRepositoryInterface.php
):
Generated Repository (app/Repositories/ProductRepository.php
):
Generate Service with Interface
Generated Service Interface (app/Contracts/Services/ProductServiceInterface.php
):
Generated Service (app/Services/ProductService.php
):
Advanced Usage
Nested Namespaces
The package supports nested namespaces:
This creates:
app/Contracts/Repositories/Admin/UserRepositoryInterface.php
app/Repositories/Admin/UserRepository.php
Force Overwrite
Use the --force
flag to overwrite existing files:
Real-world Example
Here's a complete example of a User management system:
1. Generate the files:
2. Implement the Repository Interface:
3. Implement the Repository:
4. Implement the Service Interface:
5. Implement the Service:
6. Use in Controller:
โ๏ธ Configuration
The package works out of the box with sensible defaults. You can customize the behavior by publishing and editing the configuration file:
๐งช Testing
Run tests with coverage:
๐ Changelog
Please see CHANGELOG for more information on what has changed recently.
๐ค Contributing
Please see CONTRIBUTING for details.
๐ Security Vulnerabilities
If you discover a security vulnerability within this package, please send an e-mail to Taki Elias via [email protected]. All security vulnerabilities will be promptly addressed.
๐ Credits
- Taki Elias
- All Contributors
๐ License
The MIT License (MIT). Please see License File for more information.
๐ Show Your Support
If this package helped you, please consider giving it a โญ on GitHub!
๐ Links
Made with โค๏ธ by Taki Elias
All versions of contract-resolver with dependencies
illuminate/support Version ^11.0|^12.0
illuminate/filesystem Version ^11.0|^12.0
illuminate/console Version ^11.0|^12.0