Download the PHP package reinfi/zf-dependency-injection without Composer

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

Configure dependency injection in Laminas or Mezzio using annotations, yaml or autowiring.

Heavily inspired by https://github.com/mikemix/mxdiModule.

=======

  1. Installation
  2. AutoWiring
  3. Attributes
  4. Annotations
  5. YAML
  6. Caching
  7. PHPStan Extension
  8. Console commands

Installation

  1. Install with Composer: composer require reinfi/zf-dependency-injection.
  2. Enable the module via config in application.config.php under modules key:

AutoWiring

To use autowiring for your service you need to specify the 'AutoWiringFactory' within the service manager configuration.

Fallback AutoWiring

If you are migrating your existing project to use zend service manager and don't want to register all autowired services by hand, you can register the abstract FallbackAutoWiringFactory factory.

Please make sure that you don't use the fallback mechanism for everything. You should try to write and register explicit factories for your services.

What can be autowired?

Every service registered within the service manager can be autowired. Plugins within the plugin manager can also be autowired. If you need to register another mapping you can simply add the following:

If your service needs the container as dependency this can also be autowired.

Add another resolver

If you like to add another resolver you can simply add one through the configuration.

It needs to implement the ResolverInterface.

Attributes

Attributes are activated if you are using a php version 8.0 or higher. To use attributes for your dependencies you need to specify the 'InjectionFactory' within the service manager configuration.

Following attributes are supported:

Also in addition there a several annotations to inject from plugin managers.

You can either pass directly the required service name or if you need options you can pass them as following:

If you need a doctrine repository there is also an attribute.

It is only constructor injection supported, if you need di from setters you need to use delegator factories.

You can add the attributes at properties or at the __construct method.

or

The order is important and you should decide between constructor or property annotations.

Annotations

To use annotations for your dependencies you need to specify the 'InjectionFactory' within the service manager configuration.

Following annotations are supported:

Also in addition there a several annotations to inject from plugin managers.

You can either pass directly the required service name or if you need options you can pass them as following:

If you need a doctrine repository there is also an annotation.

It is only constructor injection supported, if you need di from setters you need to use delegator factories.

You can add the annotations at properties or at the __construct method.

or

The order is important and you should decide between constructor or property annotations.

Adding own annotations

If you want to use your own annotation you just need to implement the AnnotationInterface.

YAML

You can specify your dependencies within a yaml file.

To enable YAML usage you need to specify the following configuration

Caching

Parsing mapping sources is very heavy. You should enable the cache on production servers. You can set up caching easily with any custom or pre-existing PSR-16 cache adapter.

You can provide a string which will be resolved by the container. The factory must return a PSR-16 cache adapter.

or you provide a factory for a cache adapter.

PHPStan Extension

As "autowiring" is always kind of magic this library ships with a PHPStan extension to solve that problem.

If you also install phpstan/extension-installer then you're all set!

Manual installation If you don't want to use `phpstan/extension-installer`, include phpstan-extension.neon in your project's PHPStan config:

The extension requires to know your service manager to find all the classes you configured for autowiring.

If you do not provide it, the PHPStan extension will simply do nothing.

For example, tests/service-manager.php would look something like this:

Console commands

FAQ

Feel free to ask any questions or open own pull requests.


All versions of zf-dependency-injection with dependencies

PHP Build Version
Package Version
Requires php Version ~8.1.0 || ~8.2.0 || ~8.3.0
laminas/laminas-servicemanager Version ^2.7 | ^3.0
laminas/laminas-modulemanager Version ^2.7
psr/simple-cache Version ^1.0 | ^2.0 | ^3.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 reinfi/zf-dependency-injection contains the following files

Loading the files please wait ....