2017 © Pedro Peláez
 

library bind-symfony-dependency-injection

Binds symfony/dependency-injection to ICanBoogie

image

icanboogie/bind-symfony-dependency-injection

Binds symfony/dependency-injection to ICanBoogie

  • Saturday, March 24, 2018
  • by olvlvl
  • Repository
  • 1 Watchers
  • 0 Stars
  • 98 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

bind-symfony-dependency-injection

Release Code Quality Code Coverage Packagist, (*1)

Together with icanboogie/service, this package binds symfony/dependency-injection to ICanBoogie and allows the container to be used to provide services., (*2)

Obtaining services

Services can be obtained using a service reference or the container., (*3)

The following example demonstrates how services can be obtain using references:, (*4)

<?php

use function ICanBoogie\Service\ref;

$reference = ref('a_callable_service');
$result = $reference(1, 2, 3);

$reference = ref('a_service');
$service = $reference->resolve();
$service->do_something();

The following example demonstrates how a service can be obtained using the container itself:, (*5)

<?php

/* @var $app \ICanBoogie\Application */
/* @var $container \Symfony\Component\DependencyInjection\Container */

$container = $app->container;
$service = $container->get('a_service');
$service->do_something();

Obtaining services bound to the application

Usually, ICanBoogie's components add getters to ICanBoogie\Application instances through the prototype system, which means you can access the initial request using $app->initial_request or the session using $app->session. Services defined this way are automatically accessible through the container as well, which means they can be used as references ref('session') or obtained through the container $app->container->get('session')., (*6)

Obtaining config parameters

All application config parameters are available as container parameters e.g. $app->container->getParameter('app.repository.cache)`., (*7)

Note: To avoid clashes, all application parameters are prefixed with app.., (*8)

Defining services

Services are defined using services.yml files in config folders. They are collected when it's time to create the container, just like regular configuration files., (*9)

The tests included in this package showcase how services.yml files can be defined in all/config and default/config. Components and modules can use this feature to register their own services and make them available to the application automatically., (*10)

About the container proxy

The service provider defined during Application::boot is an instance of ContainerProxy, which only builds the service container when a service needs to be resolved., (*11)

The following example demonstrates how the service provider and the service container can be obtained:, (*12)

<?php

use ICanBoogie\Service\ServiceProvider;

/* @var $proxy \ICanBoogie\Binding\SymfonyDependencyInjection\ContainerFactory */

$proxy = ServiceProvider::defined();
$container = $proxy->container;

Configuring the container

The container is configured using container configuration fragments:, (*13)

<?php

// config/container.php

use ICanBoogie\Binding\SymfonyDependencyInjection\ConfigBuilder;
use ICanBoogie\Binding\SymfonyDependencyInjection\Extension\ApplicationExtension;

return fn(ConfigBuilder $config) => $config
    ->add_extension(ApplicationExtension::class)
    ->enable_caching();

Continuous Integration

The project is continuously tested by GitHub actions., (*14)

Tests Static Analysis Code Style, (*15)

Code of Conduct

This project adheres to a Contributor Code of Conduct. By participating in this project and its community, you are expected to uphold this code., (*16)

Contributing

Please see CONTRIBUTING for details., (*17)

License

icanboogie/bind-symfony-dependency-injection is released under the BSD-3-Clause., (*18)

The Versions

24/03 2018

5.0.x-dev

5.0.9999999.9999999-dev https://icanboogie.org/

Binds symfony/dependency-injection to ICanBoogie

  Sources   Download

BSD-3-Clause

The Requires

 

dependency injection

24/01 2018

dev-symfony4

dev-symfony4 https://icanboogie.org/

Binds symfony/dependency-injection to ICanBoogie

  Sources   Download

BSD-3-Clause

The Requires

 

dependency injection

04/06 2017

dev-master

9999999-dev https://icanboogie.org/

Binds symfony/dependency-injection to ICanBoogie

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

dependency injection