Download the PHP package dotkernel/dot-dependency-injection without Composer

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

dot-dependency-injection

DotKernel dependency injection service.

This package can clean up your code, by getting rid of all the factories you write, sometimes just to inject a dependency or two.

OSS Lifecycle PHP from Packagist (specify version)

GitHub issues GitHub forks GitHub stars GitHub license

Build Static codecov docs-build

Installation

Install dot-dependency-injection by running the following command in your project directory:

After installing, register dot-dependency-injection in your project by adding the below line to your configuration aggregate (usually: config/config.php):

Usage

Using the AttributedServiceFactory

You can register services in the service manager using AttributedServiceFactory as seen in the below example:

NOTE

You can use only the fully qualified class name as the service key

The next step is to add the #[Inject] attribute to the service constructor with the service FQCNs to inject:

use Dot\DependencyInjection\Attribute\Inject;

The #[Inject] attribute is telling AttributedServiceFactory to inject the services specified as parameters. Valid service names should be provided, as registered in the service manager.

To inject an array value from the service manager, you can use dot notation as below

use Dot\DependencyInjection\Attribute\Inject;

which will inject $container->get('config')['debug'];.

NOTE

Even if using dot notation, AttributedServiceFactory will check first if a service name exists with that name.

Using the AttributedRepositoryFactory

You can register doctrine repositories and inject them using the AttributedRepositoryFactory as below:

The next step is to add the #[Entity] attribute in the repository class.

The name field has to be the fully qualified class name.

Every repository should extend Doctrine\ORM\EntityRepository.

Dependencies injected via the#[Entity]/#[Inject] attributes are not cached

Injecting dependencies into property setters are not supported


All versions of dot-dependency-injection with dependencies

PHP Build Version
Package Version
Requires php Version ~8.2.0 || ~8.3.0 || ~8.4.0
doctrine/orm Version ^2.9 || ^3.0
psr/container Version ^1.0 || ^2.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 dotkernel/dot-dependency-injection contains the following files

Loading the files please wait ....