Download the PHP package xou816/silex-autowiring without Composer

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

silex-autowire

A service to autowire them all! For Silex.

Requirements

PHP 5.5+

Installation

Through Composer: composer require xou816/silex-autowiring.

The service is then available as .

Usage

Basics

Constructor injection

Call the wire method to let the autowiring service create your instances.

The resulting instance of Bar can be found using $app['autowiring']->provider(Bar::class);. If you only need the service name, use the name method.

Every dependency of Bar has to be known to the AutowiringService!

You can pass an array of arguments to wire : these arguments will be passed in order wherever an argument could not be resolved to a service.

Controller injection

You can entirely avoid ever calling provider or name, as your wired services can be directly injected in controllers, alongside the usual Request or Application objects.

Closure injection

You can also inject services in a closure, using invoke:

If you want to delay execution of a closure (that is, obtain a closure), use partial instead:

Interfaces

The autowiring service can also inject services based on interface rather than class. If multiple services implement the same interface, the last service to be wired is used.

It is very useful to painlessly switch implementations of an interface.

Injecting other services

Exposing built-in services

If you wish to use a service shipped with Silex or a provider, you can use the expose method. For instance:

The AutowiringService itself is exposed, and can therefore be injected!

Custom service providers

You can control how an instance will be created using provide.

Injecting any service

You may also inject any other service, even plain PHP objects (for which type hinting cannot be used) such as arrays or integers, as long as they are available in the Pimple container.

In order to do that, add a dependency to a SilexAutowiring\Injectable\Injectable:

The autowiring service knows how to inject the correct service as it infers the service's name from the constructor argument's name (fooOptions being converted from camel case to snake case). Since an instance of Injectable has to be passed to the constructor, you can retrieve the real service by calling get.

If you intend to inject a configuration array, you can instead use SilexAutowiring\Injectable\Configuration, which works the exactly like Injectable (both implement the SilexAutowiring\Injectable\InjectableInterface), but has array access.

Property injection

It is not possible to rely on type hinting to inject services on properties. Therefore, this feature is intended for configuration instead.

It resolves names much like with Injectables, but injects plain values instead.

Warning: injected values on properties are only available after construction.

Injection resolver

You might dislike the way Injectable and configure handle names (from snake case to camel case). It is possible to tweak this behaviour by providing (using wire for instance!) a custom implementation of SilexAutowiring\Injectable\InjectableResolver. This task is made easier by extending the SilexAutowiring\Injectable\AbstractCompositeKeyResolver, which allows handling identifiers such as foo_options.baz above.

You may also just wire the SilexAutowiring\Injectable\IdentityResolver class into your app to use a simpler resolution mechanism (no casing style alteration).

Experimental

You may also use the SilexAutowiring\Traits\Autowire and SilexAutowiring\Traits\Autoconfigure traits instead of calling wire and configure.

This is however not completely equivalent and likely worse in terms of performance.


All versions of silex-autowiring with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5
silex/silex Version v2.*
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 xou816/silex-autowiring contains the following files

Loading the files please wait ....