Download the PHP package njasm/container without Composer

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

Build Status Code Coverage Scrutinizer Code Quality Total Downloads Latest Stable Version License HHVM Status

Dependency Container / Service Locator

Features

Requirements

Installation

Include njasm\container in your project, by adding it to your composer.json file.

Usage

To create a container, simply instantiate the Container class.

Using Alias

There are time that your key are too long to be convenient for your client code, one example for instance, is when binding an interface to an implementation or when using for your key the FQCN of your classes.

Defining Services

Services are defined with two params. A key and a value. The order you define your services is irrelevant.

Defining Services - Primitive data-types

Defining Services - Binding Services (Lazy Loading)

You can bind a key to a instantiable FCQN value.

If you want to bind a Service, and register that Service as a Singleton Service.

Both Container::bind and Container::bindSingleton uses Lazy Loading approach, so that \My\Namespace\SomeClass will only be evaluated/instantiated when MyKey is requested.

When binding a service, constructor dependencies can be declared, public attributes be set and methods called with arguments, so they are injected/setted when instantiating the service.

Defining Services - Objects (Eager Loading)

Overwriting existent declared dependencies is also possible for set definitions.

Defining Services - Complex builds (Lazy Loading)

There are time when you'll want to instantiate an object, but the build process is reall complex and you want to control that process. You use anonymous functions for that.

Defining Services - Complex builds With Nested Dependencies (Lazy Loading)

Creation of nested dependencies is also possible. You just need to pass the container to the closure.

Defining Singleton Services

For registering singleton services, you use the singleton method invocation.

Defining Sub/Nested Containers

Nesting container is possible as long as you use an existing Container Adapter for your application existing container. The Adapter class must implement the ServicesProviderInterface for more examples please see the Adapterfolder.

Automatic Resolution of Services

When the Container is requested for a service that is not registered, it will try to find the class, and will automatically try to resolve your class's constructor dependencies.

Roadmap

In no Particular order - check Milestones for a more organized picture.

Contributing

Do you wanna help on feature development/improving existing code through refactoring, etc? Or wanna discuss a feature/bug/idea? Issues and Pull Requests are welcome as long as you follow some guidelines for PRs:

Pull Requests must:


All versions of container with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3
container-interop/container-interop 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 njasm/container contains the following files

Loading the files please wait ....