PHPackages                             cable/cable-container - 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. [Framework](/categories/framework)
4. /
5. cable/cable-container

ActiveLibrary[Framework](/categories/framework)

cable/cable-container
=====================

Container Component for CableFramework

1.2.8(9y ago)01548MITPHP

Since May 27Pushed 9y ago1 watchersCompare

[ Source](https://github.com/CableFramework/ServiceContainer)[ Packagist](https://packagist.org/packages/cable/cable-container)[ RSS](/packages/cable-cable-container/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (3)Versions (29)Used By (8)

ServiceContainer
================

[](#servicecontainer)

CableFramework service container

Create new instance
-------------------

[](#create-new-instance)

```
$container = \Cable\Container\Factory::create();
```

Add a new service
-----------------

[](#add-a-new-service)

```
// you can give an anonymous function
$container->add('test', function(){
  return new Test();
});

// you can give the name of class

$container->add('test', Test::class);

// you can give the already exists class instance

$container->add('test', new Test());
```

Resolve the service
-------------------

[](#resolve-the-service)

```
$test = $container->resolve('test');

// you can give arguments,
// they will be used in constructor calling,
// of course if you didnt give an instance

$test->resolve('test', array('message' => 'hello world'));
```

Expectations
------------

[](#expectations)

```
//you may want to check resolved value is an instance of something
// well you can to that like that

$resolved= $container->resolve('test');

if(!$resolved instanceof MyTestInterface){

}

// the problem that you may want to check multipile interfaces
// well, you can do that like that

try{

// you can always give an array like, expect('test', [MyInterface::class, MySecondInterface::class]);
$container->expect('test', MyTestInterface::class);
}catch(ExpectationException $e){
  echo "give me something valid";
}
// if test doesnot return an instanceof MyTestInterface
// container will throw an expectation exception
```

ServiceProviders
----------------

[](#serviceproviders)

```
class Provider extends ServiceProvider{
   public function register(){}
   public function boot(){
     $this->getContainer()->add('test', Test::class);
   }
}

$container = \Cable\Container\Factory::create();

$container->addProvider(Provider::class);

// now you can resolve the 'test' service

$test = $container->resolve('test');
```

tag
---

[](#tag)

```
$container->tag([Deneme::class, Test::class], 'test');

list($deneme, $test) = $container->tagged('test');
```

Using Annotations
-----------------

[](#using-annotations)

#### Provider Annotation

[](#provider-annotation)

You can put a @Provider annotation into class comment doc

@Provider will be trigged when you are trying to resolve that class

```
/**
 *
 * @Provider("Your\Provide\Class")
 * // you can give multiple providers like @Provider({"FirstProviderClass", "SecondProviderClass"})
 */
class TestClass{

}
```

#### Inject Annotation

[](#inject-annotation)

You can put @Inject Annotation into any method

```
use Cable\Container\Annotations\Inject;

$container->add("my_alias_to_resolve", function(){
      return "hello world";
});

class TestClass{

    /**
     *
     * @Inject({"$test": "my_alias_to_resolve"})
     *
     */
    public function __construct($test){

    }

}
```

Same as ;

```
$container->when(Test::class)
          ->needs("test")
          ->give(function(){
              return $this->getContainer()->make("my_alias_to_resolve");
          });
```

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~1 days

Total

28

Last Release

3290d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3c3f1e53b43ef665cfe41f9c7fa30ca07d8c615020c30eeccdc4be0209a32bc3?d=identicon)[anonymframework](/maintainers/anonymframework)

---

Top Contributors

[![anonymframework](https://avatars.githubusercontent.com/u/13378594?v=4)](https://github.com/anonymframework "anonymframework (80 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/cable-cable-container/health.svg)

```
[![Health](https://phpackages.com/badges/cable-cable-container/health.svg)](https://phpackages.com/packages/cable-cable-container)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.8k532.1M19.5k](/packages/laravel-framework)[symfony/symfony

The Symfony PHP framework

31.4k86.9M2.2k](/packages/symfony-symfony)[cakephp/cakephp

The CakePHP framework

8.8k19.1M1.7k](/packages/cakephp-cakephp)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M196](/packages/sulu-sulu)[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k12](/packages/tempest-framework)[typo3/cms

TYPO3 CMS is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.

1.2k1.9M122](/packages/typo3-cms)

PHPackages © 2026

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