Download the PHP package aatis/dependency-injection without Composer

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

Aatis DI

Installation

Usage

Requirements

Set the environment variable APP_ENV to the name of the environment you want to use.

Create the container builder with the context of your app ($_SERVER).

Exclude files

Precise the files that are not services.

Service config

You can manage in which environment your service must be loaded and the arguments to pass to the constructor.

You can also precise the class to use for the dependency when it is an interface.

Finally, you can give extra tags to any service.

environment and tags are optional

the key of an argument must have the same name as in the constructor

Interface into constructor

When an interface is requested into the constructor of a service, the DI will try to find a service implementing this interface into your app.

If multiple services implement the interface, the DI will pick the first one found or an already instancied service implementing the interface.

If you want to use a specific service, don't forget to declare it into the declaration of the service.

Otherwise if your want to use a specific service of the vendor, do the previous step and precise it into the includes_services part of the config.

Env variable into constructor

You can request for a env variable directly into the constructor of a service.

the name of the variable must start with $_ and be followed by the env variable name in lowercase

Container uses

Get and Set

With the container, you can get and set any service / env variable you want with the methods get() and set() of the container.

However, to set a service, you must give an instance of the Service class. You can create it with the ServiceFactory service.

APP_ENV_VARNAME must start with "APP"

Get by tag(s)

You can get services by tag(s) with the getByTag() and getByTags method of the Container.

You can also request to get Service instances instead of the instance of the services with precise true in the second argument.

Get by interface(s)

You can get services by interface(s) with the getByInterface() and getByInterfaces method of the Container.

Like tags, you can also request to get Service instances instead of the instance of the services with precise true in the second argument.

ServiceInstanciator

You can use the ServiceInstanciator service and the setInstance() method of the Service class to instanciate a service into the container.

You can choose between two methods to instanciate a service. For the first one, you must inform the arguments to pass to the constructor into the config. For the second one, you must create the instance yourself.


$service = $container->get(ServiceFactory::class)->create('Namespace\To\The\Service');

// Method 1
$instance = $container->get(ServiceInstanciator::class)->instanciate($service)

// Method 2
$instance = new Namespace\To\The\Service($arg1, $arg2, ...);

$service->setInstance($instance);
$container->set('Namespace\To\The\Service', $service);

All versions of dependency-injection with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
symfony/yaml Version ^6.3
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 aatis/dependency-injection contains the following files

Loading the files please wait ....