PHP Classes
elePHPant
Icontem

CakePHP 2.x Container: Interoperable container integration with CakePHP

Recommend this page to a friend!
  Info   View files Documentation   View files View files (7)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2016-08-22 (1 month ago) RSS 2.0 feedNot enough user ratingsTotal: 97 This week: 4All time: 8,457 This week: 256Up
Version License PHP version Categories
cakephp-container 1.0.0MIT/X Consortium ...5.3PHP 5, Libraries, Design Patterns, PSR
Description Author

This package is a interoperable container integration with CakePHP.

It extends the CakePHP base component class and implements the service container interface, so application services and other types of applications not based on CakePHP can be easily used with CakePHP.

Innovation Award
PHP Programming Innovation award nominee
August 2016
Number 7
Dependency injection is design pattern often used implement functionality on one class using objects from external classes without hardcoding the dependency between the two classes.

Several PHP frameworks implement their own dependency injection containers but since each one implements it in a different way, a generic container interface was defined to allow to call components of one framework to be called from by components of any other framework.

The package implements a component with the generic dependency injection container interface so application services and other types of applications not based on CakePHP can be easily used with CakePHP.

Manuel Lemos
Picture of Nerijus
  Performance   Level  
Name: Nerijus <contact>
Classes: 2 packages by
Country: Lithuania Lithuania
Innovation award
Innovation award
Nominee: 2x

Details

Container Interop in CakePHP

Container Interoperability plugin for CakePHP 2.x. This plugin adds the ability to easy configure any service containers compatible with container-interop.

It provides the clean component to access you container or services in container. Also you get container registered in ClassRegistry that allows you to gradually migrate your application.

Installation

Installation through composer is HIGHLY RECOMMENDED. Installation can be done manually, but requires a lot more steps and is not supported officially.

composer

composer require eimanavicius/cakephp-container-interop

or add requirement to your composer.json file manually and don't forget to run composer update

{
  "require": {
    "eimanavicius/cakephp-container-interop": "^0.0"
  }
}

Configuration

Plugin loading

Load the plugin as any other plugin in app/Config/bootstrap.php:

CakePlugin::load('ContainerInterop', array('bootstrap' => true));

The bootstrap file must be loaded, to set up all configurations needed.

Add pre-configured service container

By installing Zend Service Manager plugin.

More pre-configured service containers will be provided as they appear.

Or configure your container instance

By default container is loaded from file app/Config/container.php (file should return configured service container instance as in sample below). You can change file location by specifying config value before plugin load:

Configure::write('Interop\Container\ContainerInterface', 'app/Config/container.php');

app/Config/container.php sample

<?php

// Build container
$container = new SomeServiceContainer();

return $container;
  Files folder image Files  
File Role Description
Files folder imageConfig (1 file)
Files folder imageController (1 directory)
Files folder imageTest (1 directory)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE.txt Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  Config  
File Role Description
  Accessible without login Plain text file bootstrap.php Conf. Configuration script

  Files folder image Files  /  Controller  
File Role Description
Files folder imageComponent (1 file)

  Files folder image Files  /  Controller  /  Component  
File Role Description
  Plain text file ContainerComponent.php Class Class source

  Files folder image Files  /  Test  
File Role Description
Files folder imageCase (1 file, 1 directory)

  Files folder image Files  /  Test  /  Case  
File Role Description
Files folder imageController (1 directory)
  Plain text file ClassRegistryConfigTest.php Class Class source

  Files folder image Files  /  Test  /  Case  /  Controller  
File Role Description
Files folder imageComponent (1 file)

  Files folder image Files  /  Test  /  Case  /  Controller  /  Component  
File Role Description
  Plain text file ContainerComponentTest.php Class Class source

Downloadcakephp-container-2016-08-22.zip 4KB
Downloadcakephp-container-2016-08-22.tar.gz 3KB
Install with ComposerInstall with Composer
Needed packages  
Class DownloadWhy it is needed Dependency
CakePHP 2 Zend Service Manager integration Download .zip .tar.gz Service Container implementation Provider (Zend Service Manager) Optional
 Version Control Reuses Unique User Downloads Download Rankings  
 100%1
Total:97
This week:4
All time:8,457
This week:256Up