Skip to content

Commit

Permalink
News entry for 4.3 + website update
Browse files Browse the repository at this point in the history
  • Loading branch information
mnapoli committed Aug 12, 2014
1 parent d220bb7 commit 2c40a32
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 13 deletions.
20 changes: 11 additions & 9 deletions news/11-php-di-4-3-released.md
Expand Up @@ -6,7 +6,7 @@ date: August 12th 2014
---

I am happy to announce that PHP-DI version 4.3 has been released. This version contains features that have all been
implemented by contributors other than me, this is very encouraging :) This is also the fastest version to be released,
implemented by contributors other than me, this is very encouraging :) This is also the quickest release,
since 4.2 was released only 14 days ago.

It comes without any BC break, and with a new main feature: `DI\env()` to import **environment variables**.
Expand All @@ -23,7 +23,7 @@ return [

'db.url' => DI\factory(
function (DI\Container $container) {
$url = isset($_SERVER['DATABASE_URL'])
return isset($_SERVER['DATABASE_URL'])
? $_SERVER['DATABASE_URL']
: 'postgresql://user:pass@localhost/db';
}
Expand All @@ -32,7 +32,7 @@ return [
];
```

This might be a common situation for other developers, especially those deploying their applications to
This might be a common situation for some developers, especially those deploying their applications to
systems like Heroku, or otherwise following the principles of [12-factor applications](http://12factor.net/config).

Since 4.3, this can be written like this:
Expand All @@ -44,7 +44,7 @@ return [
```

The first parameter to `DI\env()` is the name of the environment variable to read,
the second parameter is the default value to use in the event that the environment variable is not defined.
the second parameter is the default value to use if the environment variable is not defined.

If the environment variable is not defined and no default is provided, a `DefinitionException`
is thrown when attempting to resolve the value.
Expand All @@ -54,7 +54,7 @@ Finally, default values can reference other definitions using `DI\link()`:
```php
return [
'default-dsn' => 'postgresql://user:pass@localhost/db',
'dsn' => DI\env('DATABASE_URL', DI\link('my-app.default-dsn')),
'dsn' => DI\env('DATABASE_URL', DI\link('default-dsn')),
];
```

Expand All @@ -71,16 +71,18 @@ $container->call(['MyClass', 'method]);

If the method is not static, `MyClass` will be resolved using the container.

Don't know what `Container::call()` is? [Check out the "Container API" documentation](http://php-di.org/doc/container.html).

## `DI\FactoryInterface` and `DI\InvokerInterface` are auto-registered

## FactoryInterface and InvokerInterface are auto-registered

*contributed by [@drealecs](https://github.com/drealecs)*

Before 4.3, if you wanted to use `DI\FactoryInterface` or `DI\InvokerInterface`, you needed to define
them in the configuration.
Before 4.3, if you wanted to inject `DI\FactoryInterface` or `DI\InvokerInterface`, you needed to bind
them in the configuration to `DI\Container`.

They are now auto-registered (just like `DI\ContainerInterface`) as links to `DI\Container` so that
you can inject them without any configuration needed.
you can inject them without any configuration.

If you had previously defined them, there is no problem: your definitions always override the internal ones.

Expand Down
25 changes: 22 additions & 3 deletions website/blog.twig
Expand Up @@ -10,6 +10,25 @@

{% block blogcontent %}

<div class='white-card recent-post clearfix extra-padding'>
<h5 class='recent-post-header'>
PHP-DI 4.3 released
</h5>

<p class='post-content'>
I am happy to announce that PHP-DI version 4.3 has been released.
This version contains features that have all been
implemented by contributors other than me, this is very encouraging :)
This is also the quickest release, since 4.2 was released only 14 days ago.
</p>
<p class="post-content">
It comes without any BC break, and with a new main feature: <code>DI\env()</code>
to import <strong>environment variables</strong>.
</p>
<a href="{{ baseUrl }}/news/11-php-di-4-3-released.html" class="btn btn-extra pull-right">
Read More &gt;</a>
</div>

<div class='white-card recent-post clearfix extra-padding'>
<h5 class='recent-post-header'>
PHP-DI 4.2 released
Expand Down Expand Up @@ -160,6 +179,9 @@
Latest posts
</h3>
<ul>
<li>
<a href="{{ baseUrl }}/news/11-php-di-4-3-released.html">PHP-DI 4.3 released</a>
</li>
<li>
<a href="{{ baseUrl }}/news/10-php-di-4-2-released.html">PHP-DI 4.2 released</a>
</li>
Expand All @@ -181,9 +203,6 @@
<li>
<a href="{{ baseUrl }}/news/04-php-di-3-4.html">PHP-DI 3.4 released</a>
</li>
<li>
<a href="{{ baseUrl }}/news/03-php-di-3-3.html">PHP-DI 3.3 released</a>
</li>
</ul>
</div>

Expand Down
2 changes: 1 addition & 1 deletion website/home.twig
Expand Up @@ -70,7 +70,7 @@

<div class="white-card">
<strong>New blog post:</strong>
<a href="{{ baseUrl }}/news/10-php-di-4-2-released.html">PHP-DI 4.2 released</a>
<a href="{{ baseUrl }}/news/11-php-di-4-3-released.html">PHP-DI 4.3 released</a>
</div>

<div class='row'>
Expand Down

0 comments on commit 2c40a32

Please sign in to comment.