Download the PHP package phower/container without Composer

On this page you can find all versions of the php package phower/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

Phower Container

Dependency Injection for PHP complaint with PSR-11 Container.

Requirements

Phower Container requires:

Implementations

This package implements:

Instalation

Add Phower Container to any PHP project using Composer:

Usage

In software engineering, dependency injection is a software design pattern that implements inversion of control for resolving dependencies.

A dependency is an object that can be used (a service). An injection is the passing of a dependency to a dependent object (a client) that would use it.

In order to solve the above we can use a container which knows how to resolve names into instances. This way we can simply inject our container into our classes and then just ask it to provide he required dependencies.

Instances

Creating and using a container is quite simple:

However this is not very efficient in case you need to register hundreds or thousands of instances, which will take too much time and computer resources each time the container goes to be initialized.

Entries

A more efficient way is to simply add entries to the container which are then resolved to the right instance at runtime:

Factories

But what if our dependency requires arguments, which may also be retrieved from inside the container? The solution is to register a factory class instead of our final class.

First let's create a factory class:

Note that your factories must always implement the Phower\Container\FactoryInterface.

Then register the factory and the required argument on the container:

Abstract Factories

Another way to retrieve dependencies from a container is to use an abstract (dynamic) factory. This way you can instantiate dependencies base on a name patter or a namespace.

Let's say you have many classes under the namespace 'Some':

Instead of registering them separatedly we just need a single abstract factory:

Note that your abstract factories must always implement the Phower\Container\AbstractFactoryInterface.

Then register the abstract factory on the container:

Aliases

Sometimes you need to have different names to the same entry on the container. This can be achieved adding aliases instead of duplicating references:

Create container from config

Most of times it would be better to create the container from a (huge) configuration array. This can be done using the static create method with an array of entries as argument:

Running Tests

Tests are available in a separated namespace and can run with PHPUnit in the command line:

Coding Standards

Phower code is written under PSR-2 coding style standard. To enforce that CodeSniffer tools are also provided and can run as:

Reporting Issues

In case you find issues with this code please open a ticket in Github Issues at https://github.com/phower/container/issues.

Contributors

Open Source is made of contribuition. If you want to contribute to Phower please follow these steps:

  1. Fork latest version into your own repository.
  2. Write your changes or additions and commit them.
  3. Follow PSR-2 coding style standard.
  4. Make sure you have unit tests with full coverage to your changes.
  5. Go to Github Pull Requests at https://github.com/phower/container/pulls and create a new request.

Thank you!

Changes and Versioning

All relevant changes on this code are logged in a separated log file.

Version numbers follow recommendations from Semantic Versioning.

License

Phower code is maintained under The MIT License.


All versions of container with dependencies

PHP Build Version
Package Version
Requires php Version ^5.6 || ^7.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 phower/container contains the following files

Loading the files please wait ....