New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

sassnowski/yii-provider-registry

A Laravel inspired way to register services into your yii application.
16 2

Larablocks Analysis

sassnowski/yii-provider-registry works with any PHP project: the latest release (1.0.0, May 12, 2016) doesn't depend on Laravel.

Recommendation checks

Not advised

Not advised: no release or commit in over 2 years.

  • No release or commit in over 2 years
  • No release in the last 12 months (last: May 12, 2016)
  • 0 downloads a month (needs 10,000)
  • 2 GitHub stars (needs 100)

State

Likely abandoned
  • No release or commit in over 2 years.
  • Last stable release: May 12, 2016.
  • No releases in the last 12 months.
  • First released: May 12, 2016.
  • 0 open issues on GitHub.

Data from Packagist and GitHub, checked by Larablocks on Nov 26, 2026.

Install
composer require sassnowski/yii-provider-registry
Latest Version:1.0.0
License:MIT
Last Updated:May 12, 2016
Links: GitHub  ·  Packagist
Maintainer: ksassnowski

Yii Provider Registry

Provides a Laravel-inspired way to register services into a Yii application.

Installation

Require the library via Composer.

composer require sassnowski/yii-provider-registry

Setup

Change the last few lines in your web/index.php to this:

$app = new yii\web\Application($config)

(new \Sassnowski\Yii2\ProviderRegistry\ProviderRegistry(\Yii::$container))->bootstrap();

$app->run();

Create a bootstrap folder in your application root and put a services.php file into it. This file should simply return an array of Bootstrapper classes.

<?php

return [
    \Acme\Providers\MyProvider::class,
    \Acme\Providers\AnotherProvider::class,
    \Acme\Providers\Mailing\MailProvider::class,
];

These classes should implement a bootstrap method. This method will be called during the bootstrapping process and receives the applications DI Container as its only parameter. Inside this method you can then register classes into the Yii DI Container.

<?php

namespace Acme\Providers;

use yii\di\Container;

class MyProvider
{
    public function bootstrap(Container $container)
    {
        $container->set(
            \Acme\Services\MySickServiceInterface::class,
            \Acme\Services\MySickServiceImplementation::class
        );
    }
}

That's it! Now you can use the service anywhere inside the application either by explicitly resolving it out of the container via get or by type hinting it in the constructor. Refer to the (Yii Documentation)[http://www.yiiframework.com/doc-2.0/guide-concept-di-container.html] for the full list of possibilities!

License

MIT

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

670,032,257 9,703
laravel/framework

The Laravel Framework.

640,572,096 35,338
laravel/tinker

Powerful REPL for the Laravel framework.

546,909,908 7,440
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

465,816,364 607
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

431,187,642 4,660

Version History

Version Released License
1.0.0 MIT