Download the PHP package php-di/silex-bridge without Composer

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

PHP-DI integration with Silex

Build Status Coverage Status

Installation

Usage

In order to benefit from PHP-DI's integration in Silex, you only need to use DI\Bridge\Silex\Application instead of the original Silex\Application.

Here is the classic Silex example updated:

Benefits

Using PHP-DI in Silex allows you to use all the awesome features of PHP-DI to wire your dependencies (using the definition files, autowiring, annotations, …).

Another big benefit of the PHP-DI integration is the ability to use dependency injection inside controllers, middlewares and param converters:

Dependency injection works using type-hinting:

Controllers as services

With Silex and Pimple, you can define controllers as services by installing the ServiceControllerServiceProvider and using a specific notation.

With the PHP-DI bridge, you can natively define any type of callable based on services:

You will notice above that we give the class name and not an object: PHP-DI will instantiate the instance (and inject dependencies inside it) only if it is used.

Again you will notice that we pass the class name and not an instance. PHP-DI will correctly detect that this is an invokable class and will instantiate it.

Middlewares, route variable converters, error handlers and view handlers

The callable resolution described above (for "controllers as services") applies for registering other Silex objects:

For example you can define a middleware like so and let PHP-DI instantiate it:

Configuring the container

You can configure PHP-DI's container by creating your own ContainerBuilder and passing it to the application:

Silex service providers

Silex offers several "service providers" to pre-configure some 3rd party libraries, for example Twig or Doctrine. You can still use those service providers with this integration (even though in bigger projects you might want to configure everything yourself).

Here is the example of the TwigServiceProvider:

Since Twig services are registered using a custom name instead of the actual class name (e.g. twig instead of the Twig_Environment class name), you cannot inject such dependencies into closures. If you want to inject in controller closures, you can alias entries with PHP-DI:


All versions of silex-bridge with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4
php-di/php-di Version ~5.0
php-di/invoker Version ~1.3
silex/silex Version ~1.3
pimple/pimple Version ~1.1
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 php-di/silex-bridge contains the following files

Loading the files please wait ....