Download the PHP package baublet/dependency-container without Composer

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

DependencyContainer

Build Status

For simple dependency injection

Why?

Sometimes you need dependencies across your application, plugin, or some other system that doesn't itself have a way to handle it (e.g., WordPress). So include this project as a submodule and inject dependencies into your classes at your leisure. Use a container when you don't want to pollute your constructors with a ton of dependencies.

This container also only loads dependencies when a class tries to access the dependency in question. That's why all of our injections are declared as functions. For more information on this, see below.

It's PSR compliant, implementing the (proposed) Container interfaces for the API. If the API changes in the interfaces, I'll update these to match.

This means that the API for this is subject to change, so please read any documentation before upgrading.

Installation

Add baublet/dependency-container to the required packages portion of your composer.json file, or, from the command line:

Example

I've tried to make the API fairly simple. First, require the container module and declare a new container.

Dependencies are declared as functions, so that you can ensure your dependencies are only loaded when called. This allows you to use this container as a registry of dependencies in a particular module that, when called, may or may not use all of its dependencies in a given call.

To declare a dependency:

In the above code, some/big/dependency/class.php is only required and SomeBigDependencyClass is only initialized when you call $dependencies->get("my-dependency");.

Testing

This code is tested using Travis CI and plain PHP assertions. No testing framework required. Just hop into the test directory and run the test:


All versions of dependency-container with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.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 baublet/dependency-container contains the following files

Loading the files please wait ....