Download the PHP package xphere/tag-bundle without Composer

On this page you can find all versions of the php package xphere/tag-bundle. 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 tag-bundle

xphere/tag-bundle

Are you tired to add CompilerPasses just to collect some services tagged on your container?

Say NO to most of them with this bundle!

SensioLabsInsight

⚠ Note ⚠

Mind the namespace change

Why I would want that?

More than often you want to search for services tagged with a particular tag and call some method in your service with them. This can be done with a custom CompilerPass.

Another use case is to inject a service to every other that is tagged with a particular tag. An example:

This boilerplate is repeated once and again in every project I've seen. With this bundle you can say goodbye to most of this compiler passes.

Features

With this bundle you can:

Compatibility

Tested under Symfony2, from 2.0.10 to 2.6.3

Installation

From composer/packagist

Usage

Consumer

You can define a service as a "tag consumer" of another tag, and let the bundle make the relationship between them. Just tag your service as a tag.consumer and specify which tag to collect and which method to call.

The first example using this bundle is just configuration:

The only change is the tag in my_plugin_enumerator. The CompilerPass boilerplate is gone.

This calls PluginEnumerator::addPlugin with each my_plugin, but you can also call this once with all services using the bulk parameter.

This is calling PluginEnumerator::addPlugins just once, with an array of the services.

To make the service consume its dependencies through it's constructor, just omit the method attribute in the tag.

Injectable

You can define a service as a "tag injectable" from another tag, and let the bundle do the hard work. Just tag your service as a tag.injectable and specify which tag to collect and which method to call in each service.

The second example in the introduction will be like this:

The only change is the tag in my_event_dispatcher. The CompilerPass boilerplate is also gone.

This forces all my_event_dispatcher.aware to have a setMyEventDispatcher method. But you can change that for a particular service with the method parameter.

Now it's calling setEventDispatcher for UselessService, and the default method for the others.

Advanced usage

That's all about the basics, there are more options available for major control over your dependencies, though.

Order

You can specify the order in which services will be injected into the consumer with the order field in each tag. Lower orderings have priority over higher orders. Tagged services with no order will be injected after ordered ones. In case of a tie between orders, keeps symfony declaration order.

Indexing bulk services

When bulk is active, you can specify a key which will be used to index each tag, instead of a plain array.

This results in the next injection:

You can also specify that multiple elements will collide with same index and needs to collect arrays instead of single services with the multiple field in your consumer definition.

This results in the next injection:

Multiple also honors ordering, if specified.

Reference

As usual, dependencies are injected directly to your service, but you can inject your dependencies as service ids instead by setting the field reference to false in your consumer definition.

InstanceOf

You can force your dependencies to be an instance of a class or interface with the field instanceof in your consumer definition.

No bundle

You can add manually TagConsumerPass or TagInjectablePass (or both) without adding the "whole" bundle to your Kernel, even customize the tag names used to apply them.

In your Kernel:


All versions of tag-bundle with dependencies

PHP Build Version
Package Version
Requires symfony/dependency-injection Version >=2.0.10
symfony/http-kernel Version >=2.0.10
symfony/config Version >=2.0.10
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 xphere/tag-bundle contains the following files

Loading the files please wait ....