<div id="configuration" class='container'>

    <h2><a href="#configuration">Expressive configuration</a></h2>

    <p class="text-center">
        PHP-DI's configuration is written in PHP, allowing to benefit from auto-completion, static analysis and refactoring support with any IDE.
    </p>

    <div class='row'>
        <div class='col-md-6'>
            <h4>
                Object creation
                <a class="read-more" href="doc/php-definitions.html#objects" title="Creating objects with PHP-DI">read more</a>
            </h4>
<pre><code class="php">return [
    Foo::class => create()
        ->constructor(
            get(Bar::class)
        )
];</code></pre>
        </div>
        <div class='col-md-6'>
            <h4>
                Inline factories
                <a class="read-more" href="doc/php-definitions.html#factories" title="Writing factories using closures or classes">read more</a>
            </h4>
<pre><code class="php">return [
    Foo::class => function ($container) {
        $bar = $container->get(Bar::class);
        return new Foo($bar);
    }
];</code></pre>
        </div>
    </div>

    <div class="row">
        <div class="col-md-6">
            <h4>
                Interface-to-implementation binding
                <a class="read-more" href="doc/php-definitions.html#aliases" title="Aliasing container entries">read more</a>
            </h4>
<pre><code class="php">return [
    NotifierInterface::class => get(EmailNotifier::class)
];</code></pre>
        </div>
        <div class="col-md-6">
            <h4>
                Environment variables
                <a class="read-more" href="doc/php-definitions.html#environment-variables" title="Resolving environment variables">read more</a>
            </h4>
<pre><code class="php">return [
    'db.host' => env('DB_HOST', 'default value')
];</code></pre>
        </div>
    </div>

    <hr>

    <p>
        The configuration format <a href="{{ baseUrl }}/news/06-php-di-4-0-new-definitions.html" title="PHP-DI's new definition format">has been imagined</a> as a successor of XML and YAML, taking advantages of all the latest features of PHP:
    </p>

    <div class="row">
        <div class='col-md-4'>
            <h4>PHP 5.4 short arrays</h4>
<pre><code class="php">return [


];</code></pre>
        </div>
        <div class='col-md-4'>
            <h4>PHP 5.5 <code>::class</code> magic constant</h4>
<pre><code class="php">return [
    Foo::class => DI\create()
      ->constructor(DI\get(Bar::class))
];</code></pre>
        </div>
        <div class='col-md-4'>
            <h4>PHP 5.6 <code>use function</code></h4>
<pre><code class="php">return [
    Foo::class => create()
      ->constructor(get(Bar::class))
];</code></pre>
        </div>
    </div>

    <p class="text-center">
        <a href="doc/php-definitions.html" class="btn btn-default" title="PHP-DI configuration reference">Learn more</a>
    </p>

</div>
