Download the PHP package acclimate/container without Composer

On this page you can find all versions of the php package acclimate/container. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package container

Acclimate - Container Adapters

License Latest Stable Version Build Status Code Coverage Scrutinizer Code Quality

Get Acclimated! Use any third-party dependency injection containers and service locators in your code by adapting them to a common container interface. Acclimate was created by Jeremy Lindblom.

Introduction

It seems like every framework has its own container object. They come in many shapes and sizes (service locator, service manager, service container, dependency injection (DI) container, registry, etc.), but are all generally used in a similar way.

The wide variety of implementations makes it hard for other frameworks, framework-agnostic libraries, or some applications to get the full benefits of using an inversion of control (IoC) system, because they either need to:

  1. Write their own container implementation (NIH Syndrome)
  2. Have a long-term dependency on a particular, third-party container implementation (and force that dependency on their users, which may already be using a different container implementation)
  3. Implement an abstraction layer to support one or more third-party containers

Acclimate is a library that does #3 for you. It provides a set of adapters for the most popular container implementations. This allows you to adapt, or "acclimate", instances of these containers to a common, normalized, and interoperable interface. Using Acclimate allows your framework, library, or application to retrieve items from the container objects of third-party libraries. That's interoperability!

The Container Interface

The ContainerInterface used by Acclimate comes from the psr/container project. It attempts to normalize the various implementations of container interfaces (whether they be for service locators, dependency injection containers, or something else similar) to a simple, readonly interface, that allows users to retrieve entries from any third-party container in a consistent way.

Acclimate v1 and previous use the similar container-interop/container-interop standard

The ContainerInterface looks like this:

Installation

Install the acclimate/container package using Composer. This will also also install psr/container, which provides the ContainerInterface.

Warning: If you install Acclimate with dev dependencies, you will get A LOT of packages from various frameworks (e.g., ZF, Symfony, Laravel, etc.). These packages are required for testing only to ensure that all of the adapter classes work correctly. They are not included when you run Composer with --no-dev.

Note: We recommend using Composer and Composer's autoloader to load this library. If you are not using Composer's autoloader, be sure to use a PSR-4 compliant autoloader and map the namespace prefix Acclimate\Container\ to the src/ directory in order to correct autoload the classes.

Basic Usage

Acclimate: Container provides a ContainerAcclimator object that is used to adapt a container object to a normalized ContainerInterface. In terms of design patterns, it's essentially a factory for adapters.

Here is an example of how to use the ContainerAcclimator:

Now you can use the container from your favorite framework and acclimate it into your other code. :-)

Container Decorators

The default behavior of a container implementing the ContainerInterface is to throw a Psr\Container\NotFoundExceptionInterface when using get() to retrieve an entry that does not actually exist in the container. In some cases, you may want to change this default behavior to do something else instead (e.g., return null). Container decorators allow you to easily modify the behavior of a container. acclimate\container ships with 3 decorators (NullOnMissContainer, CallbackOnMissContainer, and FailoverOnMissContainer), but allows you to easily create your own by extending Acclimate\Container\Decorator\AbstractContainerDecorator.

Here is an example of how to use the NullOnMissContainer decorator:

Composite Container

You can create composite containers if your use case requires that you need to fetch data from two or more different container objects. For the sake of the following example, we will say the you have a Symfony Container stored in the variable $sfContainer, and a Zend ServiceManager stored in the variable $zfContainer.

This is essentially a way to support container chaining, but uses the Composite design pattern instead of the Chain of Command design pattern. You can also use the FailoverOnMissContainer decorator to support chaining.

Supported Containers

Also, the Silex Application and other projects descending from Pimple can be used with Acclimate as well.

Deprecated Containers

Support for the following containers is deprecated in version 1.1, and will be removed in 2.0:

What if the Container I use is not supported?

Please consider submitting a Pull Request with an adapter for your container and a corresponding test.

Before you get to that point though, you can create the adapter yourself (which is really easy to do actually, just look at the included ones), and use the ContainerAcclimator::registerAdapter() method to wire up your adapter to Acclimate. You will need to provide the fully qualified class name (FQCN) of both the adapter class and the base class or interface of the container you want to be able to adapt (the "adaptee").

Assuming that you have a $container object that implements Your\Favorite\ContainerInterface, and you have written an adapter class named Your\Favorite\ContainerAdapter, here is an example of how you can make these work in Acclimate:

Resources


All versions of container with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6.0
psr/container Version ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package acclimate/container contains the following files

Loading the files please wait ....