Skip to content

Latest commit

 

History

History
38 lines (27 loc) · 1.28 KB

container.md

File metadata and controls

38 lines (27 loc) · 1.28 KB
layout language version title keywords
default
en
4.0
Dependency Injection Container (PSR-11)
psr-11, di, container, dependency injection

Dependency Injection Container (PSR-11)


![](/assets/images/document-status-stable-success.svg) ![](/assets/images/version-{{ page.version }}.svg)

Overview

Phalcon\Container is an implementation of the PSR-11 Container interface as defined by PHP-FIG.

This component aids with receiving and setting services in the DI container

NOTE: Phalcon\Container is not a real implementation of PSR-11. For now it acts as a proxy to the Phalcon\Di container. In future versions, we will implement this component fully and it will replace the current Dependency Injection container.

{: .alert .alert-warning }

Activation

To set the container up, you first need to have a Phalcon\Di object already set up.

<?php

use Phalcon\Di\FactoryDefault;
use Phalcon\Container;

$default   = new FactoryDefault();
$container = new Container($default);

$request = $container->get('request');