• Stars
    star
    168
  • Rank 217,504 (Top 5 %)
  • Language
    PHP
  • License
    BSD 3-Clause "New...
  • Created over 6 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

PSR-11 compatible DI container and injector

Yii Dependency Injection


Latest Stable Version Total Downloads Build status Scrutinizer Code Quality Code Coverage Mutation testing badge static analysis type-coverage

PSR-11 compatible dependency injection container that's able to instantiate and configure classes resolving dependencies.

Features

  • PSR-11 compatible.
  • Supports property injection, constructor injection and method injection.
  • Detects circular references.
  • Accepts array definitions. You can use it with mergeable configs.
  • Provides optional autoload fallback for classes without explicit definition.
  • Allows delegated lookup and has a composite container.
  • Supports aliasing.
  • Supports service providers.
  • Has state resetter for long-running workers serving many requests, such as RoadRunner or Swoole.
  • Supports container delegates.

Requirements

  • PHP 8.0 or higher.
  • Multibyte String PHP extension.

Installation

You could install the package with composer:

composer require yiisoft/di

Using the container

Usage of the DI container is simple: You first initialize it with an array of definitions. The array keys are usually interface names. It will then use these definitions to create an object whenever the application requests that type. This happens, for example, when fetching a type directly from the container somewhere in the application. But objects are also created implicitly if a definition has a dependency to another definition.

Usually one uses a single container for the whole application. It's often configured either in the entry script such as index.php or a configuration file:

use Yiisoft\Di\Container;
use Yiisoft\Di\ContainerConfig;

$config = ContainerConfig::create()
    ->withDefinitions($definitions);

$container = new Container($config);

You could store the definitions in a .php file that returns an array:

return [
    EngineInterface::class => EngineMarkOne::class,
    'full_definition' => [
        'class' => EngineMarkOne::class,
        '__construct()' => [42], 
        '$propertyName' => 'value',
        'setX()' => [42],
    ],
    'closure' => fn (SomeFactory $factory) => $factory->create('args'),
    'static_call_preferred' => fn () => MyFactory::create('args'),
    'static_call_supported' => [MyFactory::class, 'create'],
    'object' => new MyClass(),
];

You can define an object in several ways:

  • In the simple case, an interface definition maps an id to a particular class.
  • A full definition describes how to instantiate a class in more detail:
    • class has the name of the class to instantiate.
    • __construct() holds an array of constructor arguments.
    • The rest of the config are property values (prefixed with $) and method calls, postfixed with (). They're set/called in the order they appear in the array.
  • Closures are useful if instantiation is tricky and can better done in code. When using these, arguments are auto-wired by type. ContainerInterface could be used to get current container instance.
  • If it's even more complicated, it's a good idea to move such a code into a factory and reference it as a static call.
  • While it's usually not a good idea, you can also set an already instantiated object into the container.

See yiisoft/definitions for more information.

After you configure the container, you can obtain a service can via get():

/** @var \Yiisoft\Di\Container $container */
$object = $container->get('interface_name');

Note, however, that it's bad practice using a container directly. It's much better to rely on auto-wiring as provided by the Injector available from the yiisoft/injector package.

Using aliases

The DI container supports aliases via the Yiisoft\Definitions\Reference class. This way you can retrieve objects by a more handy name:

use Yiisoft\Di\Container;
use Yiisoft\Di\ContainerConfig;

$config = ContainerConfig::create()
    ->withDefinitions([
        EngineInterface::class => EngineMarkOne::class,
        'engine_one' => EngineInterface::class,
    ]);

$container = new Container($config);
$object = $container->get('engine_one');

Composite containers

A composite container combines many containers in a single container. When using this approach, you should fetch objects only from the composite container.

use Yiisoft\Di\CompositeContainer;
use Yiisoft\Di\Container;
use Yiisoft\Di\ContainerConfig;

$composite = new CompositeContainer();

$carConfig = ContainerConfig::create()
    ->withDefinitions([
        EngineInterface::class => EngineMarkOne::class,
        CarInterface::class => Car::class
    ]);
$carContainer = new Container($carConfig);

$bikeConfig = ContainerConfig::create()
    ->withDefinitions([
        BikeInterface::class => Bike::class
    ]);

$bikeContainer = new Container($bikeConfig);
$composite->attach($carContainer);
$composite->attach($bikeContainer);

// Returns an instance of a `Car` class.
$car = $composite->get(CarInterface::class);
// Returns an instance of a `Bike` class.
$bike = $composite->get(BikeInterface::class);

Note, that containers attached earlier override dependencies of containers attached later.

use Yiisoft\Di\CompositeContainer;
use Yiisoft\Di\Container;
use Yiisoft\Di\ContainerConfig;

$carConfig = ContainerConfig::create()
    ->withDefinitions([
        EngineInterface::class => EngineMarkOne::class,
        CarInterface::class => Car::class
    ]);

$carContainer = new Container($carConfig);

$composite = new CompositeContainer();
$composite->attach($carContainer);

// Returns an instance of a `Car` class.
$car = $composite->get(CarInterface::class);
// Returns an instance of a `EngineMarkOne` class.
$engine = $car->getEngine();

$engineConfig = ContainerConfig::create()
    ->withDefinitions([
        EngineInterface::class => EngineMarkTwo::class,
    ]);

$engineContainer = new Container($engineConfig);

$composite = new CompositeContainer();
$composite->attach($engineContainer);
$composite->attach($carContainer);

// Returns an instance of a `Car` class.
$car = $composite->get(CarInterface::class);
// Returns an instance of a `EngineMarkTwo` class.
$engine = $composite->get(EngineInterface::class);

Using service providers

A service provider is a special class that's responsible for providing complex services or groups of dependencies for the container and extensions of existing services.

A provider should extend from Yiisoft\Di\ServiceProviderInterface and must contain a getDefinitions() and getExtensions() methods. It should only provide services for the container and therefore should only contain code that's related to this task. It should never implement any business logic or other functionality such as environment bootstrap or applying changes to a database.

A typical service provider could look like:

use Yiisoft\Di\Container;
use Yiisoft\Di\ServiceProviderInterface;

class CarFactoryProvider extends ServiceProviderInterface
{
    public function getDefinitions(): array
    {
        return [
            CarFactory::class => [
                'class' => CarFactory::class,
                '$color' => 'red',
            ], 
            EngineInterface::class => SolarEngine::class,
            WheelInterface::class => [
                'class' => Wheel::class,
                '$color' => 'black',
            ],
            CarInterface::class => [
                'class' => BMW::class,
                '$model' => 'X5',
            ],
        ];    
    }
     
    public function getExtensions(): array
    {
        return [
            // Note that Garage should already be defined in a container 
            Garage::class => function(ContainerInterface $container, Garage $garage) {
                $car = $container
                    ->get(CarFactory::class)
                    ->create();
                $garage->setCar($car);
                
                return $garage;
            }
        ];
    } 
}

Here you created a service provider responsible for bootstrapping of a car factory with all its dependencies.

An extension is callable that returns a modified service object. In this case you get existing Garage service and put a car into the garage by calling the method setCar(). Thus, before applying this provider, you had an empty garage and with the help of the extension you fill it.

To add this service provider to a container, you can pass either its class or a configuration array in the extra config:

use Yiisoft\Di\Container;
use Yiisoft\Di\ContainerConfig;

$config = ContainerConfig::create()
    ->withProviders([CarFactoryProvider::class]);

$container = new Container($config);

When you add a service provider, DI calls its getDefinitions() and getExtensions() methods immediately and both services and their extensions get registered into the container.

Container tags

You can tag services in the following way:

use Yiisoft\Di\Container;
use Yiisoft\Di\ContainerConfig;

$config = ContainerConfig::create()
    ->withDefinitions([  
        BlueCarService::class => [
            'class' => BlueCarService::class,
            'tags' => ['car'], 
        ],
        RedCarService::class => [
            'definition' => fn () => new RedCarService(),
            'tags' => ['car'],
        ],
    ]);

$container = new Container($config);

Now you can get tagged services from the container in the following way:

$container->get('tag@car');

The result is an array that has two instances: BlueCarService and RedCarService.

Another way to tag services is setting tags via container constructor:

use Yiisoft\Di\Container;
use Yiisoft\Di\ContainerConfig;

$config = ContainerConfig::create()
    ->withDefinitions([  
        BlueCarService::class => [
            'class' => BlueCarService::class,
        ],
        RedCarService::class => fn () => new RedCarService(),
    ])
    ->withTags([
        // "car" tag has references to both blue and red cars
        'car' => [BlueCarService::class, RedCarService::class]
    ]);

$container = new Container($config);

Resetting services state

Despite stateful services isn't a great practice, these are often inevitable. When you build long-running applications with tools like Swoole or RoadRunner you should reset the state of such services every request. For this purpose you can use StateResetter with resetters callbacks:

$resetter = new StateResetter();
$resetter->setResetters([
    MyServiceInterface::class => function () {
        $this->reset(); // a method of MyServiceInterface
    },
]);

The callback has access to the private and protected properties of the service instance, so you can set initial state of the service efficiently without creating a new instance.

You should trigger the reset itself after each request-response cycle. For RoadRunner, it would look like the following:

while ($request = $psr7->acceptRequest()) {
    $response = $application->handle($request);
    $psr7->respond($response);
    $application->afterEmit($response);
    $container
        ->get(\Yiisoft\Di\StateResetter::class)
        ->reset();
    gc_collect_cycles();
}

Setting resetters in definitions

You define the reset state for each service by providing "reset" callback in the following way:

use Yiisoft\Di\Container;
use Yiisoft\Di\ContainerConfig;

$config = ContainerConfig::create()
    ->withDefinitions([
        EngineInterface::class => EngineMarkOne::class,
        EngineMarkOne::class => [
            'class' => EngineMarkOne::class,
            'setNumber()' => [42],
            'reset' => function () {
                $this->number = 42;
            },
        ],
    ]);

$container = new Container($config);

Note: resetters from definitions work only if you don't set StateResetter in definition or service providers.

Configuring StateResetter manually

To manually add resetters or in case you use Yii DI composite container with a third party container that doesn't support state reset natively, you could configure state resetter separately. The following example is PHP-DI:

MyServiceInterface::class => function () {
    // ...
},
StateResetter::class => function () {
    $resetter = new StateResetter();
    $resetter->setResetters([
        MyServiceInterface::class => function () {
            $this->reset(); // a method of MyServiceInterface
        },
    ]);
    return $resetter;
}

Specifying metadata for non-array definitions

To specify some metadata, such as in cases of "resetting services state" or "container tags," for non-array definitions, you could use the following syntax:

LogTarget::class => [
    'definition' => static function (LoggerInterface $logger) use ($params) {
        $target = ...
        return $target;
    },
    'reset' => function () use ($params) {
        ...
    },
],

Now you've explicitly moved the definition itself to "definition" key.

Delegates

Each delegate is a callable returning a container instance that's used in case DI can't find a service in a primary container:

function (ContainerInterface $container): ContainerInterface
{

}

To configure delegates use extra config:

use Yiisoft\Di\Container;
use Yiisoft\Di\ContainerConfig;

$config = ContainerConfig::create()
    ->withDelegates([
        function (ContainerInterface $container): ContainerInterface {
            // ...
        }
    ]);


$container = new Container($config);

Tuning for production

By default, the container validates definitions right when they're set. In the production environment, it makes sense to turn it off:

use Yiisoft\Di\Container;
use Yiisoft\Di\ContainerConfig;

$config = ContainerConfig::create()
    ->withValidate(false);

$container = new Container($config);

Strict mode

Container may work in a strict mode, that's when you should define everything in the container explicitly. To turn it on, use the following code:

use Yiisoft\Di\Container;
use Yiisoft\Di\ContainerConfig;

$config = ContainerConfig::create()
    ->withStrictMode(true);

$container = new Container($config);

Further reading

Benchmarks

To run benchmarks execute the next command

composer require phpbench/phpbench $ ./vendor/bin/phpbench run

Result example

\Yiisoft\Di\Tests\Benchmark\ContainerBench

benchConstructStupid....................I4 [μ Mo]/r: 438.566 435.190 (μs) [μSD μRSD]/r: 9.080μs 2.07%
benchConstructSmart.....................I4 [μ Mo]/r: 470.958 468.942 (μs) [μSD μRSD]/r: 2.848μs 0.60%
benchSequentialLookups # 0..............R5 I4 [μ Mo]/r: 2,837.000 2,821.636 (μs) [μSD μRSD]/r: 34.123μs 1.20%
benchSequentialLookups # 1..............R1 I0 [μ Mo]/r: 12,253.600 12,278.859 (μs) [μSD μRSD]/r: 69.087μs 0.56%
benchRandomLookups # 0..................R5 I4 [μ Mo]/r: 3,142.200 3,111.290 (μs) [μSD μRSD]/r: 87.639μs 2.79%
benchRandomLookups # 1..................R1 I2 [μ Mo]/r: 13,298.800 13,337.170 (μs) [μSD μRSD]/r: 103.891μs 0.78%
benchRandomLookupsComposite # 0.........R1 I3 [μ Mo]/r: 3,351.600 3,389.104 (μs) [μSD μRSD]/r: 72.516μs 2.16%
benchRandomLookupsComposite # 1.........R1 I4 [μ Mo]/r: 13,528.200 13,502.881 (μs) [μSD μRSD]/r: 99.997μs 0.74%
\Yiisoft\Di\Tests\Benchmark\ContainerMethodHasBench

benchPredefinedExisting.................R1 I4 [μ Mo]/r: 0.115 0.114 (μs) [μSD μRSD]/r: 0.001μs 1.31%
benchUndefinedExisting..................R5 I4 [μ Mo]/r: 0.436 0.432 (μs) [μSD μRSD]/r: 0.008μs 1.89%
benchUndefinedNonexistent...............R5 I4 [μ Mo]/r: 0.946 0.942 (μs) [μSD μRSD]/r: 0.006μs 0.59%
8 subjects, 55 iterations, 5,006 revs, 0 rejects, 0 failures, 0 warnings 
(best [mean mode] worst) = 0.113 [4,483.856 4,486.051] 0.117 (μs) 
⅀T: 246,612.096μs μSD/r 43.563μs μRSD/r: 1.336%

Warning! These summary statistics can be misleading. You should always verify the individual subject statistics before drawing any conclusions.

Legend

  • μ: Mean time taken by all iterations in variant.
  • Mo: Mode of all iterations in variant.
  • μSD: μ standard deviation.
  • μRSD: μ relative standard deviation.
  • best: Maximum time of all iterations (minimal of all iterations).
  • mean: Mean time taken by all iterations.
  • mode: Mode of all iterations.
  • worst: Minimum time of all iterations (minimal of all iterations).

Command examples

  • Default report for all benchmarks that outputs the result to CSV-file

$ ./vendor/bin/phpbench run --report=default --progress=dots --output=csv_file

Generated MD-file example

DI benchmark report

suite: 1343b1dc0589cb4e985036d14b3e12cb430a975b, date: 2020-02-21, stime: 16:02:45

benchmark subject set revs iter mem_peak time_rev comp_z_value comp_deviation
ContainerBench benchConstructStupid 0 1000 0 1,416,784b 210.938μs -1.48σ -1.1%
ContainerBench benchConstructStupid 0 1000 1 1,416,784b 213.867μs +0.37σ +0.27%
ContainerBench benchConstructStupid 0 1000 2 1,416,784b 212.890μs -0.25σ -0.18%
ContainerBench benchConstructStupid 0 1000 3 1,416,784b 215.820μs +1.60σ +1.19%
ContainerBench benchConstructStupid 0 1000 4 1,416,784b 212.891μs -0.25σ -0.18%
ContainerBench benchConstructSmart 0 1000 0 1,426,280b 232.422μs -1.03σ -0.5%
ContainerBench benchConstructSmart 0 1000 1 1,426,280b 232.422μs -1.03σ -0.5%
ContainerBench benchConstructSmart 0 1000 2 1,426,280b 233.398μs -0.17σ -0.08%
ContainerBench benchConstructSmart 0 1000 3 1,426,280b 234.375μs +0.69σ +0.33%
ContainerBench benchConstructSmart 0 1000 4 1,426,280b 235.351μs +1.54σ +0.75%
... skipped ... ... ... ... ... ... ... ...
ContainerMethodHasBench benchPredefinedExisting 0 1000 0 1,216,144b 81.055μs -0.91σ -1.19%
ContainerMethodHasBench benchPredefinedExisting 0 1000 1 1,216,144b 83.985μs +1.83σ +2.38%
ContainerMethodHasBench benchPredefinedExisting 0 1000 2 1,216,144b 82.032μs 0.00σ 0.00%
ContainerMethodHasBench benchPredefinedExisting 0 1000 3 1,216,144b 82.031μs 0.00σ 0.00%
ContainerMethodHasBench benchPredefinedExisting 0 1000 4 1,216,144b 81.055μs -0.91σ -1.19%
... skipped ... ... ... ... ... ... ... ...

Legend

  • benchmark: Benchmark class.
  • subject: Benchmark class method.
  • set: Set of data (provided by ParamProvider).
  • revs: Number of revolutions (represent the number of times that the code is executed).
  • iter: Number of iteration.
  • mem_peak: (mean) Peak memory used by iteration as retrieved by memory_get_peak_usage.
  • time_rev: Mean time taken by all iterations in variant.
  • comp_z_value: Z-score.
  • comp_deviation: Relative deviation (margin of error).
  • Aggregate report for the lookup group that outputs the result to console and CSV-file

$ ./vendor/bin/phpbench run --report=aggregate --progress=dots --output=csv_file --output=console --group=lookup

Notice

Available groups: construct lookup has

Generated MD-file example

DI benchmark report

suite: 1343b1d2654a3819c72a96d236302b70a504dac7, date: 2020-02-21, stime: 13:27:32

benchmark subject set revs its mem_peak best mean mode worst stdev rstdev diff
ContainerBench benchSequentialLookups 0 1000 5 1,454,024b 168.945μs 170.117μs 169.782μs 171.875μs 0.957μs 0.56% 1.00x
ContainerBench benchSequentialLookups 1 1000 5 1,445,296b 3,347.656μs 3,384.961μs 3,390.411μs 3,414.062μs 21.823μs 0.64% 19.90x
ContainerBench benchSequentialLookups 2 1000 5 1,445,568b 3,420.898μs 3,488.477μs 3,447.260μs 3,657.227μs 85.705μs 2.46% 20.51x
ContainerBench benchRandomLookups 0 1000 5 1,454,024b 169.922μs 171.875μs 171.871μs 173.828μs 1.381μs 0.80% 1.01x
ContainerBench benchRandomLookups 1 1000 5 1,445,296b 3,353.515μs 3,389.844μs 3,377.299μs 3,446.289μs 31.598μs 0.93% 19.93x
ContainerBench benchRandomLookups 2 1000 5 1,445,568b 3,445.313μs 3,587.696μs 3,517.823μs 3,749.023μs 115.850μs 3.23% 21.09x
ContainerBench benchRandomLookupsComposite 0 1000 5 1,454,032b 297.852μs 299.610μs 298.855μs 302.734μs 1.680μs 0.56% 1.76x
ContainerBench benchRandomLookupsComposite 1 1000 5 1,445,880b 3,684.570μs 3,708.984μs 3,695.731μs 3,762.695μs 28.297μs 0.76% 21.80x
ContainerBench benchRandomLookupsComposite 2 1000 5 1,446,152b 3,668.946μs 3,721.680μs 3,727.407μs 3,765.625μs 30.881μs 0.83% 21.88x

Legend

  • benchmark: Benchmark class.
  • subject: Benchmark class method.
  • set: Set of data (provided by ParamProvider).
  • revs: Number of revolutions (represent the number of times that the code is executed).
  • its: Number of iterations (one measurement for each iteration).
  • mem_peak: (mean) Peak memory used by each iteration as retrieved by memory_get_peak_usage.
  • best: Maximum time of all iterations in variant.
  • mean: Mean time taken by all iterations in variant.
  • mode: Mode of all iterations in variant.
  • worst: Minimum time of all iterations in variant.
  • stdev: Standard deviation.
  • rstdev: The relative standard deviation.
  • diff: Difference between variants in a single group.

Testing

Unit testing

The package is tested with PHPUnit. To run tests:

./vendor/bin/phpunit

Mutation testing

The package tests are checked with Infection mutation framework with Infection Static Analysis Plugin. To run it:

./vendor/bin/roave-infection-static-analysis-plugin

Static analysis

The code is statically analyzed with Psalm. To run static analysis:

./vendor/bin/psalm

License

The Yii Dependency Injection is free software. It's released under the terms of the BSD License. Please see LICENSE for more information.

Maintained by Yii Software.

Support the project

Open Collective

Follow updates

Official website Twitter Telegram Facebook Slack

More Repositories

1

yii2

Yii 2: The Fast, Secure and Professional PHP Framework
PHP
14,127
star
2

yii

Yii PHP Framework 1.1.x
PHP
4,851
star
3

yii2-app-advanced

Yii 2.0 Advanced Application Template
PHP
1,628
star
4

yii2-queue

Yii2 Queue Extension. Supports DB, Redis, RabbitMQ, Beanstalk and Gearman
PHP
1,065
star
5

yii2-app-basic

Yii 2.0 Basic Application Template
PHP
630
star
6

yii2-authclient

Yii 2 authclient extension.
PHP
455
star
7

yii2-redis

Yii 2 Redis extension.
PHP
444
star
8

yii-core

Yii Framework 3.0 core
433
star
9

yii2-elasticsearch

Yii 2 Elasticsearch extension
PHP
428
star
10

yii2-httpclient

Yii 2 HTTP client
PHP
422
star
11

yii2-docker

Official Docker images suitable for Yii 2.0
PHP
363
star
12

yii2-mongodb

Yii 2 MongoDB extension
PHP
318
star
13

demo

Yii 3 demo application
PHP
309
star
14

yii2-imagine

Yii 2 imagine extension
PHP
282
star
15

yii2-apidoc

Yii 2 apidoc extension.
PHP
254
star
16

yii2-framework

[READ ONLY] Yii 2 framework core code only. This is a subtree split off the "yii2" repository
PHP
232
star
17

docs

Various Yii 3.0 related documentation
226
star
18

app

Yii3 application template
PHP
214
star
19

yii2-bootstrap4

Yii 2 Bootstrap 4 Extension
PHP
210
star
20

yii2-gii

Yii 2 Gii Extension
PHP
198
star
21

yii2-debug

Debug Extension for Yii 2
PHP
195
star
22

yii2-bootstrap

Yii 2 Bootstrap 3 Extension
PHP
183
star
23

yii2-coding-standards

Yii 2 coding standards
PHP
179
star
24

yii2-sphinx

Yii 2 Sphinx extension.
PHP
179
star
25

yii2-shell

Interactive shell
PHP
138
star
26

yii2-twig

Yii 2 Twig extension.
PHP
136
star
27

yii2-jui

Yii 2 JQuery UI extension.
PHP
125
star
28

db

Yii Database Library
PHP
123
star
29

yii-project-template

PHP
120
star
30

yii2-swiftmailer

Yii 2 swiftmailer extension.
PHP
114
star
31

yii2-faker

Yii 2 Faker extension
PHP
104
star
32

validator

Yii validator library
PHP
103
star
33

yii-base-web

PHP
101
star
34

yii-api

Yii REST API framework
PHP
92
star
35

yii2-composer

Yii 2 composer extension
PHP
81
star
36

yii-web

Yii web components
PHP
78
star
37

yii2-smarty

Yii 2 Smarty Extension.
PHP
72
star
38

event-dispatcher

PSR-14 event dispatcher
PHP
66
star
39

yii-dev-tool

Development environment for Yii 3 packages
PHP
65
star
40

yii-console

Yii console components
PHP
62
star
41

active-record

Active Record database abstraction layer
PHP
62
star
42

yii2-collection

Collection extension for Yii 2
PHP
62
star
43

rbac

Role based access control
PHP
59
star
44

router

Router is a request matcher and URL generator
PHP
58
star
45

yii2-bootstrap5

Yii 2 Bootstrap 5 Extension
PHP
58
star
46

app-api

API application project template
PHP
56
star
47

yii-bootstrap5

Yii Framework Bootstrap 5 support
PHP
56
star
48

yii2-codeception

Yii 2 Codeception extension (DEPRECATED)
PHP
54
star
49

view

Yii view rendering library
PHP
54
star
50

queue

Queue extension for Yii 3.0
PHP
54
star
51

yii-base-api

REST API application template
PHP
52
star
52

html

Handy library to generate HTML
PHP
51
star
53

arrays

Yii Array Helper
PHP
48
star
54

friendly-exception

An interface for an exception to be friendly
PHP
47
star
55

strings

String helper methods and an inflector
PHP
45
star
56

security

A set of classes to handle common security-related tasks
PHP
42
star
57

yii-cycle

Cycle ORM support for Yii
PHP
41
star
58

yii-docker

Official Docker images suitable for Yii 3.0+
PHP
41
star
59

router-fastroute

Yii Router FastRoute adapter
PHP
39
star
60

data

Data providers
PHP
39
star
61

injector

PSR-11 compatible injector
PHP
38
star
62

yii-masked-input

Yii Framework Masked input widget Extension
PHP
38
star
63

yii2-symfonymailer

Yii 2 Symfony mailer extension.
PHP
38
star
64

yii-dataview

Data widgets
PHP
36
star
65

form

The package helps with implementing data entry forms
PHP
36
star
66

db-mysql

MySQL and MariaDB driver for Yii Database
PHP
35
star
67

log

PSR-3 compatible logger
PHP
35
star
68

auth

PHP
33
star
69

mutex

Mutex lock implementation
PHP
32
star
70

files

Useful methods to manage files and directories
PHP
32
star
71

package-template

A template for a new package within yiisoft
PHP
32
star
72

factory

Object factory that is able to resolve dependencies from PSR-11 container
PHP
32
star
73

composer-config-plugin

Composer plugin for config assembling
PHP
31
star
74

yii-gii

Yii code generator extension
PHP
31
star
75

cache

PSR-16 compatible cache library
PHP
31
star
76

auth-jwt

PHP
31
star
77

config

Configuration management
PHP
30
star
78

access

Access checking abstraction
PHP
29
star
79

db-pgsql

PostgreSQL driver for Yii Database
PHP
28
star
80

demo-api

PHP
28
star
81

yii-debug

Yii debug panel extension
PHP
27
star
82

yii-runner-roadrunner

Web application runner for RoadRunner
PHP
27
star
83

db-migration

The package implementing migration for yiisoft/db.
PHP
27
star
84

network-utilities

Network related utilities
PHP
26
star
85

yii-jquery

Yii Framework jQuery Extension
JavaScript
26
star
86

rate-limiter

RateLimiter helps to prevent abuse by limiting the number of requests that could be me made consequentially.
PHP
26
star
87

yii-base-cli

Yii Framework Command Line Application
PHP
26
star
88

json

JSON encoding and decoding
PHP
25
star
89

yii-swagger

Swagger integration for Yii
PHP
25
star
90

db-oracle

Oracle driver for Yii Database
PHP
25
star
91

db-sqlite

SQLite driver for Yii Database
PHP
25
star
92

http

Handy HTTP utility such as method constants and status codes
PHP
25
star
93

view-twig

Yii View Twig Renderer
PHP
24
star
94

i18n

Yii i18n
PHP
24
star
95

yii-bulma

Yii Framework Bulma Integration
PHP
24
star
96

widget

Widgets are reusable building blocks used to create complex and configurable user interface elements in an object-oriented fashion
PHP
24
star
97

aliases

Named paths and URLs storage
PHP
23
star
98

yii-auth-client

Yii Framework external authentication via OAuth and OpenID Extension
PHP
23
star
99

yii-bootstrap4

Yii Framework Bootstrap 4 support
PHP
23
star
100

csrf

PSR-15 middleware implementing CSRF protection
PHP
22
star