statflo/php-di

Dependency Injection for statflo php projects

This package's canonical repository appears to be gone and the package has been frozen as a result.

1.4.0 2020-04-22 18:51 UTC

This package is auto-updated.

Last update: 2023-01-23 02:24:04 UTC


README

installation

composer.json

{
    "require": {
        /* ... */
        "statflo/php-di": "dev-master"
    },
}

Usage

config.xml

<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://symfony.com/schema/dic/services
        http://symfony.com/schema/dic/services/services-1.0.xsd">

    <services>
        <service id="statflo.service.whatever" class="Statflo\Service\Whatever" lazy="true">
            <argument type="service" id="statflo.amqp.connection" />
            <argument>%statflo.docker_env_variable%</argument>
            <argument>your string</argument>
        </service>
    </services>
</container>

bootstrap.php

<?php

use Statflo\DI\Bootstrap;

$bootstrap = Bootstrap::run([
    'config_path' => dirname(__FILE__) . "/config",
    'parameters'  => [
        'statflo.docker_env_variable' => getenv('ENV_VAR') ?: 'fallback',
    ]
]);

$bootstrap
    ->get('statflo.service.whatever')
    ->execute()
;