PHPackages                             phpshots/bind-it - 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. phpshots/bind-it

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

phpshots/bind-it
================

A binding component for PHP applications, enabling efficient registration and resolution of abstract types.

0.1.3(1y ago)029MITPHPPHP ^7.4 || ^8.0

Since Oct 31Pushed 1y ago1 watchersCompare

[ Source](https://github.com/hakrichTech/bindIt)[ Packagist](https://packagist.org/packages/phpshots/bind-it)[ Docs](https://github.com/phpshots/common)[ RSS](/packages/phpshots-bind-it/feed)WikiDiscussions master Synced 1mo ago

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

[![Contributors](https://camo.githubusercontent.com/c5c243af10c494a46ec066b41a8fda3d3972e2c6d02a946413a91b7ae8bc6eaf/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f636f6e7472696275746f72732f6f74686e65696c647265772f426573742d524541444d452d54656d706c6174652e7376673f7374796c653d666f722d7468652d6261646765)](https://github.com/hakrichTech/bindIt/graphs/contributors)[![Forks](https://camo.githubusercontent.com/f5b690c293c5c38ddab7de81629465fb5695ad4c314c579d4fa6baeec499252b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f6f74686e65696c647265772f426573742d524541444d452d54656d706c6174652e7376673f7374796c653d666f722d7468652d6261646765)](https://github.com/hakrichTech/bindIt/network/members)[![Stargazers](https://camo.githubusercontent.com/66a38831b442988adf5ea85e6be835670cdc92e184529d1f44fa85528b24230d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f6f74686e65696c647265772f426573742d524541444d452d54656d706c6174652e7376673f7374796c653d666f722d7468652d6261646765)](https://github.com/hakrichTech/bindIt/stargazers)[![Issues](https://camo.githubusercontent.com/9d60db08e07d276bc826b77ec52d58e7410ae702676819695d96f64ef6cc90fc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6f74686e65696c647265772f426573742d524541444d452d54656d706c6174652e7376673f7374796c653d666f722d7468652d6261646765)](https://github.com/hakrichTech/bindIt/issues)[![MIT License](https://camo.githubusercontent.com/ccf868bd300b5f35fefe83aa4c571a3f35a8ab009ebd8ff94282ad0e220c8676/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6f74686e65696c647265772f426573742d524541444d452d54656d706c6174652e7376673f7374796c653d666f722d7468652d6261646765)](https://github.com/hakrichTech/bindIt/blob/master/LICENSE.txt)[![LinkedIn](https://camo.githubusercontent.com/d52963778220cbec61d6ed72270f9735024ffceeb551e5c3933d4e03b4694cf1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f2d4c696e6b6564496e2d626c61636b2e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d6c696e6b6564696e26636f6c6f72423d353535)](https://linkedin.com/in/hakeem-shamavu)

 [ ![Logo](images/logo.png) ](https://github.com/hakrichTech/bindIt)### PHPShots/bint-it \[Dependecies Injection Manager\]

[](#phpshotsbint-it-dependecies-injection-manager)

 A common library for managing Dependecies Injection in PHP.
 [**Explore the docs »**](https://github.com/hakrichTech/bindIt)

 [View Demo](https://github.com/hakrichTech/bindIt) · [Report Bug](https://github.com/hakrichTech/bindIt/issues) · [Request Feature](https://github.com/hakrichTech/bindIt/issues)

 Table of Contents1. [About The Project](#about-the-project)
    - [Built With](#built-with)
2. [Getting Started](#getting-started)
    - [Prerequisites](#prerequisites)
    - [Installation](#installation)
3. [Roadmap](#roadmap)
4. [Contributing](#contributing)
5. [License](#license)
6. [Contact](#contact)
7. [Acknowledgments](#acknowledgments)

PHPShots Bind-It
================

[](#phpshots-bind-it)

`phpshots/bind-it` is a powerful and lightweight PHP container library that simplifies dependency injection and contextual bindings. It provides intuitive methods to manage singleton instances, contextual bindings, and dependency resolution in your PHP applications.

---

Why Use Bind-It?
----------------

[](#why-use-bind-it)

- **Flexibility and Control**: Define how your application resolves dependencies with complete control over bindings, contextual mappings, and singleton instances.
- **Simplicity**: Clean and intuitive API for managing dependencies, allowing developers to focus on application logic.
- **Contextual Binding**: Bind different implementations of a dependency based on the requesting class or context.
- **Scalability**: Suitable for both small applications and large-scale systems, adapting seamlessly to growth.
- **Integration-Friendly**: Lightweight and easy to integrate into any PHP project or framework.
- **Testing Made Easy**: Improves testability by decoupling dependencies, making integration with PHPUnit or other testing frameworks seamless.

---

Features
--------

[](#features)

- **Bind and Resolve**: Easily bind classes or interfaces to implementations and resolve them when needed.
- **Singletons**: Manage single instances across the application lifecycle.
- **Contextual Binding**: Bind different implementations of a dependency based on the requesting class or context.
- **Automatic Resolution**: Automatically resolve class dependencies using reflection.
- **Flexible Configuration**: Adapt bindings for varying application needs.

---

Getting Started
---------------

[](#getting-started)

Follow these steps to set up and start using the Bind-it library in your PHP project.

### Prerequisites

[](#prerequisites)

Before you begin, ensure you have the following installed:

- PHP (version 8.2 or higher) ```
    apt install php
    ```
- Composer (for dependency management) ```
    apt install composer
    ```

### Installation

[](#installation)

1. **Clone the Repository**: Start by cloning the repository to your local machine:

    ```
    git clone https://github.com/hakrichTech/bindIt.git
    ```
2. Navigate to the Project Directory

    ```
    cd bindIt
    ```
3. **Install Dependencies**: Use Composer to install the required dependencies:

    ```
    composer install
    ```
4. **Or install the package using composer**:

    ```
     composer require phpshots/bind-it
    ```

Basic Setup
-----------

[](#basic-setup)

1. **Include the Library**: In your PHP script, include the Composer autoload file to access the Bind-it library:

    ```
    require 'vendor/autoload.php'; // Adjust the path as necessary
    ```
2. **Binding and Resolving Services**: Bind a class or interface to a concrete implementation:

    ```
    use PHPShots\Common\Container;

    $container = new Container();

    $container->bind('ConditionalService', function ($container) {
        return new ConditionalService();
    });

    $service = $container->make('ConditionalService');
    ```
3. **Singleton Binding**: Ensure only one instance of a class is shared across the application:

    ```
    $container->singleton('GreetingService', GreetingService::class);

    $instance1 = $container->make('GreetingService');
    $instance2 = $container->make('GreetingService');

    if($instance1 === $instance2):; // Both instances are the same
    endif;
    ```
4. **Contextual Binding**: Provide different implementations of a dependency based on the requesting class:

    ```
    use PHPShots\Common\ContextualBindingBuilder;

    $contextualBinding = new ContextualBindingBuilder($container, ConcreteClass::class);
    $contextualBinding->needs(AbstractClass::class)->give(ConcreteImplementation::class);

    $instance = $container->make(ConcreteClass::class);
    if($instance->getDependency() instanceof ConcreteImplementation):
    {
      echo true;
    }
    ```

    Or use shorthand:

    ```
    $container->addContextualBinding(ConcreteClass::class, AbstractClass::class, ConcreteImplementation::class);
    ```
5. **Resolving with Dependencies**: Automatically resolve dependencies for complex class hierarchies:

    ```
    $container->bind(AbstractClass::class, ConcreteImplementation::class);
    $container->bind(ConcreteClass::class, ClassWithDependency::class);

    $resolved = $container->make(ConcreteClass::class);
    if($resolved instanceof ClassWithDependency){
      echo true;
    }
    if($resolved->getDependency() instanceof ConcreteImplementation){
      echo true;
    }
    ```

Contributing
------------

[](#contributing)

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request

License
-------

[](#license)

Distributed under the MIT License. See `LICENSE.txt` for more information.

Contact
-------

[](#contact)

Shamavu Rasheed - [@hakeem-shamavu](www.linkedin.com/in/hakeem-shamavu) -

Project Link:

Acknowledgments
---------------

[](#acknowledgments)

Use this space to list resources you find helpful and would like to give credit to. I've included a few of my favorites to kick things off!

- [Choose an Open Source License](https://choosealicense.com)
- [GitHub Emoji Cheat Sheet](https://www.webpagefx.com/tools/emoji-cheat-sheet)
- [Malven's Flexbox Cheatsheet](https://flexbox.malven.co/)
- [Malven's Grid Cheatsheet](https://grid.malven.co/)
- [Img Shields](https://shields.io)
- [GitHub Pages](https://pages.github.com)
- [Font Awesome](https://fontawesome.com)
- [React Icons](https://react-icons.github.io/react-icons/search)

([back to top](#top))

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance42

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 50% 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 ~26 days

Total

4

Last Release

482d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a7d468154d9ff24ced9c7e5efb399c025798d0ac07b4b1d46550fe52208b1c01?d=identicon)[hakrichTeam](/maintainers/hakrichTeam)

---

Top Contributors

[![Alshatri](https://avatars.githubusercontent.com/u/34820611?v=4)](https://github.com/Alshatri "Alshatri (4 commits)")[![hakrichTech](https://avatars.githubusercontent.com/u/74720541?v=4)](https://github.com/hakrichTech "hakrichTech (4 commits)")

---

Tags

phpabstractioncomponentbinding

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/phpshots-bind-it/health.svg)

```
[![Health](https://phpackages.com/badges/phpshots-bind-it/health.svg)](https://phpackages.com/packages/phpshots-bind-it)
```

###  Alternatives

[phpoffice/common

PHPOffice Common

23512.3M36](/packages/phpoffice-common)[jaxon-php/jaxon-core

Jaxon is an open source PHP library for easily creating Ajax web applications

73142.3k25](/packages/jaxon-php-jaxon-core)[tomatophp/filament-icons

Picker &amp; Table Column &amp; Icons Provider for FilamentPHP

3598.2k13](/packages/tomatophp-filament-icons)[ebidtech/collection

A set of interfaces and traits to speed up the creation of collections

13119.8k6](/packages/ebidtech-collection)

PHPackages © 2026

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