service-binding

Implement dependency injection and service container binding patterns in Laravel applications.

Updated Sep 19, 2026
One-click install
npx skills add https://github.com/idehen-divine/lumished --skill service-binding-idehen-divine
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: service-binding
Source: https://github.com/idehen-divine/lumished/tree/main/.agents/skills/service-binding
Command: npx skills add https://github.com/idehen-divine/lumished --skill service-binding-idehen-divine

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Managing dependencies between repositories, services, and models in Laravel can become tangled and hard to test. This Skill explains how automatic interface-to-implementation binding works in the Laravel Repository With Service package and how to configure, verify, and troubleshoot container resolution. ## Core Features & Use Cases - Automatic Binding: Understand how models, repositories, and services are resolved from the container by naming convention without configuration. - Advanced Binding Patterns: Implement singleton, conditional, decorator, and context-based bindings in service providers. - Testing Support: Mock or fake repository interfaces in tests using Mockery, instance(), or custom fake implementations. - Use Case: When a controller type-hints UserRepository and resolution fails, use this Skill to verify bindings, check naming conventions, clear caches, and confirm the interface maps to UserRepositoryImplement. ## Quick Start Ask the AI to explain how to bind a UserRepository interface to its implementation and inject it into a Laravel controller.

Frequently Asked Questions about service-binding

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I bind an interface to an implementation in Laravel?▼

Use the service container's bind() method in a service provider's register() method, passing the interface and implementation class names. The Repository With Service package also binds interfaces automatically when implementations follow the RepositoryImplement naming convention.

How to mock a repository in Laravel tests?▼

Create a Mockery mock of the repository interface, define expected method calls with shouldReceive, then bind it to the container using $this->app->bind() or $this->instance(). Services resolved afterward will receive the mock instead of the real implementation.

Why is my Laravel service not resolving from the container?▼

Resolution failures usually come from unpublished config, mismatched naming conventions, or wrong namespaces. Verify the interface and implementation follow the configured suffixes, confirm files exist in the expected directories, and run php artisan config:clear.

Can I bind different implementations based on environment in Laravel?▼

Yes, use conditional binding by checking $this->app->environment() inside the register() method and binding different implementations per condition. You can also use contextual binding with when()->needs()->give() to vary implementations by consuming class.

What is the difference between bind and singleton in Laravel?▼

bind() creates a new instance on every resolution, while singleton() registers the binding so the same instance is returned each time. Use singleton for stateless services where shared state is safe and desired.