Download the PHP package vertilia/container without Composer

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

container

Basic Service Container implementation providing psr/container-implementation.

Also known as Dependency Injection Container or Service Locator.

See PSR-11 for more information.

Use case

Step 1: define a list of rules to create objects of needed types

Here you may use some different formats to specify how objects of specific classes will be created:

  1. instantiating via callback. Defines a callback that will return a new object instance. In our example when we'll ask for the EnvMockInterface we will receive an instance of EnvMock

  2. instantiating via array of service names. If object creation needs a list of other objects for its constructor, we provide their names in an array. This way container will first instantiate these dependencies and then will call the class constructor passing dependencies as parameters. In our case the container will proceed in the following way:

    return new ServiceMock(new EnvMock); (here EnvMockInterface::class dependency will be resolved by a previous rule).

  3. instantiating via callback with additional params allowed. Same callback than in the first rule, but with additional arguments. Use this form when specific objects need additional arguments to pass into constructor. You can specify a fixed number of arguments or use php-5.6 specific ... operator.

  4. it is also possible to just return existing objects and even scalars, as shown in 3 last examples.

You can have as many rule files as needed, so each module in your application may come with its own descriptions.

Step 2: instantiate ServiceContainer with the list of rule files

You may now ask the $app service container to return you the object of needed class. It will take all the necessary actions to find it in its store or create it if necessary.

Please see more usage cases in tests/.

Final note

Service Containers together with Dependency Injection techniques do a great job to remove singletons from our applications, help decouple our code, make it more testable and SOLID.


All versions of container with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
psr/container Version ^1
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 vertilia/container contains the following files

Loading the files please wait ....