2017 © Pedro Peláez
 

library services-factory

Services container for Objective PHP

image

objective-php/services-factory

Services container for Objective PHP

  • Monday, June 4, 2018
  • by gauthier
  • Repository
  • 5 Watchers
  • 1 Stars
  • 20,127 Installations
  • PHP
  • 14 Dependents
  • 0 Suggesters
  • 5 Forks
  • 2 Open issues
  • 23 Versions
  • 14 % Grown

The README.md

Objective PHP / Services Factory Build Status

Description

Services Factory is an attempt to handle dependencies injection in an easier and more readable way compared to other available implementations., (*1)

The main main focus of this component is put on:, (*2)

  • reducing the code and configuration needed for DI mechanism
  • preserving code-insight for components built and getting their dependencies injected

The Services Factory is split in several components. Understanding each of these helps a lot in understanding the whole logic of the component:, (*3)

  • Service Specifications
    • defined by ObjectivePHP\ServicesFactory\Specification\ServiceSpecificationInterface
    • this how the service definitions are normalized, so that the Factory understands them
    • there are two default specs types provided with the component:
      • PrefabServiceSpecification
        • the most simple services ever!
        • stores a pre-instantiated object (or any other value)
      • ClassServiceSpecification
        • this one allow to define a class as template of a service
        • can get constructor arguments ("params" property)
        • optional dependencies can be set using setters ("setters" property)
        • is autowired by default
    • both types require an "id" parameter
    • the latter also supports a "static" property, to indicate whether the same instance should be returned each time the service is requested or not
  • Service Builders
    • associated to the ServiceSpecs types, builders are in charge of actually building the service according to its specs
    • there also two builders bundled with the component, one for each type:
      • PrefabServiceBuilder
      • ClassServiceBuilder
  • Factory
    • central object, it's used to register either service specs and builders
    • once setup, the Factory provide the application with services through its get(string $serviceId)method

Documentation

The component documentation is located in the docs subfolder, (*4)

The Versions

05/05 2016

v1.0.0-beta1

1.0.0.0-beta1 https://github.com/objective-php/services-factory

Services container for Objective PHP

  Sources   Download

GPL-3.0

The Requires

 

The Development Requires

services dependency injection objective php

09/08 2015