Download the PHP package fmasa/auto-di without Composer

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

Service auto registration and configuration for Nette DI

Build Status Coverage Status

fmasa\autoDI is package intended to make registration and configuration of services easier.

Future of extension

In Nette 3.0, SearchExtension was introduced. It builds on the same concept as this extension (in which I stole the concept from Symfony DependencyInjection). Unfortunately there are still a few problems that need to be fixed in order to fully replace fmasa/auto-di (i.e. nette/di#215), but it's on the other hand part of Nette DI core and supports several features, that fmasa/auto-di doesn't (yet). These are ways to register services implementing specific interface or extending specific class.

So long-term goal is to deprecate this extension in favor of SearchExtension, when (and if) SearchExtension reaches feature parity. Until then I plan to maintain and improve this package since I use it myself in many projects.

Installation

The best way to install fmasa/auto-di is using Composer:

$ composer require fmasa/auto-di

To enable auto registration register extension in your config.neon:

Pattern based definition

autoDI registers services defined by regex:

This registers every class under namespace App\Model which name ends with Repository:

There are several simple operators that can be used in patterns:

Apart from these, any PCRE regular expression can be used.

Classes and generated factories

Package supports both classes and generated factories.

Classes are matched agains class field, factories againts implement field, which corresponds to way Nette use these fields.

When using class field, all matching interfaces are skipped and vice versa.

Tags, autowiring, ...

Every option supported in DI (tags, inject, autowiring, ...) is supported with same syntax as normal service registration

The snippet above registers all classes in App\Model\Subscribers namespace with eventBus.subscriber tag.

Exclude services

Sometimes we wan't to exlude certain services from registration. For that we can use exclude field, that accepts pattern or list of patterns:

which is same as

Already registered services

When extension founds service, that is already registered (by services section, different extension or previous autoDI definition), it's skipped.

This allows manual registration of specific services that need specific configuration.

Defaults section

To specify base configuration for all services registered via autoDI, defaults section can be used:

Configuring directories

By default extension searches for services in %appDir%, but other directories can be specified:

Register services on configuration

Compiler extensions such as AutoDIExtension manipulates the DI container in two phases (configuration loading and before compilation). By default this extension registers all services before compilation. This may not be optimal if you wan't to use this extension with other extensions such as decorator.

You can enforce registration in configuration phase by setting registerOnConfiguration option to true.

When no service is registered for configuration entry, either because no class/interface matches the pattern or all matched services were already registered in container, exception is thrown. This check can be disabled by setting errorOnNotMatchedDefinitions option to false.


All versions of auto-di with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1
nette/di Version ^3.0
nette/robot-loader Version ^2.4.2 || ^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 fmasa/auto-di contains the following files

Loading the files please wait ....