Skip to content

Commit

Permalink
News entry for 3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
mnapoli committed Jul 23, 2013
1 parent 2b5db25 commit 57249a2
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 2 deletions.
2 changes: 2 additions & 0 deletions change-log.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## 3.2

Read the [news entry](news/02-php-di-3-2.md).

Small BC-break: PHP-DI 3.0 and 3.1 injected properties before calling the constructor. This was confusing and [not supported for internal classes](https://github.com/mnapoli/PHP-DI/issues/74).
From 3.2 and on, properties are injected after calling the constructor.

Expand Down
2 changes: 1 addition & 1 deletion news/01-php-di-3-1.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ I am happy to announce that I have just released PHP-DI version 3.1.

The major new feature is the **Zend Framework 1 integration**. You can now use PHP-DI very easily with ZF1, and the integration will provide you dependency injection into your controllers.

Mixing different definition sources (reflection, annotations, files, …) is now more reliable with orders and priorities. Sources are all now correctly priorized, allowing you to override definitions as you would expect. Read more in the [**Definition overriding** documentation](doc/definition-overriding.md).
Mixing different definition sources (reflection, annotations, files, …) is now more reliable with orders and priorities. Sources are all now correctly priorized, allowing you to override definitions as you would expect. Read more in the [**Definition overriding** documentation](../doc/definition-overriding.md).

Finally, [a small fix](https://github.com/mnapoli/PHP-DI/issues/79) to allow to **define `null` entries**:

Expand Down
81 changes: 81 additions & 0 deletions news/02-php-di-3-2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# PHP-DI 3.2 released

*Posted by [Matthieu Napoli](https://github.com/mnapoli) on July 23rd 2013*

I am happy to announce that I have just released PHP-DI version 3.2.

The major new feature is the full support of **Lazy Injection**. But first, let's talk about the `ContainerBuilder`.

## ContainerBuilder

The `ContainerBuilder` is an object helping you to configure and create your container.

```php
$builder = new \DI\ContainerBuilder();
$builder->setDefinitionCache(new Doctrine\Common\Cache\ArrayCache());
$builder->setDefinitionsValidation(true);

$container = $builder->build();
```

The documentation now presents 3 different configuration templates:

- development configuration
- production configuration
- lightweight configuration

Read the documentation: [Configuring the container](../doc/container-configuration.md).

## Lazy injection

Until v3.1, PHP-DI offered limited support for injecting dependencies lazily: it was restricted to property injection. Up from v3.2, there are no restrictions anymore: you can now inject lazily in constructors, setters or properties.

To achieve lazy dependencies, PHP-DI injects **proxies**. These proxies behave and look just like the real object, expect they delay loading this object until it is really used.

This can be really helpful to improve performances if you tend to inject unused dependencies.

**Credits**: lazy injection relies on creating proxy classes. PHP-DI uses [ProxyManager](https://github.com/Ocramius/ProxyManager) by Marco Pivetta, the library now used by Symfony, Zend Framework, …. A big thanks to him.

### Example

You can mark dependencies to be lazily injected, here is an example using annotations:

```php
use DI\Annotation\Inject;

class Example {
/**
* @Inject(lazy=true)
* @var My\Class
*/
protected $property;

/**
* @Inject({ "param1" = {"lazy"=true} })
*/
public function method(My\Class $param1) {
}
}
```

Here is an example using YAML:

```yaml
Example:
properties:
property:
name: My\Class
lazy: true
methods:
method:
param1:
name: My\Class
lazy: true
```

Read the full documentation: [Lazy injection](../doc/lazy-injection.md).


## Change log

Read all the changes in the [change log](../change-log.md).
4 changes: 3 additions & 1 deletion news/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# News

* June 23rd 2013. [PHP-DI 3.1 released](01-php-di-3-1.md)
- July 23rd 2013. [PHP-DI 3.2 released](02-php-di-3-2.md)

- June 23rd 2013. [PHP-DI 3.1 released](01-php-di-3-1.md)

0 comments on commit 57249a2

Please sign in to comment.