Download the PHP package acelaya/zsm-annotated-services without Composer

On this page you can find all versions of the php package acelaya/zsm-annotated-services. 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 zsm-annotated-services

Zend\ServiceManager Annotated Services

Build Status Code Coverage Scrutinizer Code Quality Latest Stable Version Total Downloads License

If you are tired of defining lots of factories in your projects just to fetch some dependencies from the ServiceManager and the create a new service instance that gets those dependencies injected, try this.

It is a component that allows to define how dependency injection has to be performed with Zend\ServiceManager via annotations.

Important! While I will keep maintaining this project and providing bugfixes, I recommend you use the ConfigAbstractFactory instead, which is included in the ServiceManager package since v3.2.

Installation

Install this component with composer.

composer require acelaya/zsm-annotated-services

Basic usage

The traditional process is that you need to create a factory for each new service. Maybe sometimes you can reuse certain factories or abstract factories, but it is not the usual case.

With this component you just need to add a simple annotation to your service constructor with the services that need to be fetched from the ServiceManager and injected.

And then, register the service with one of the provided factories (There is one factory that's used with Zend\ServiceManager 2 and another that's used with Zend\ServiceManager 3)

You just need to replace Acelaya\ZsmAnnotatedServices\Factory\V3\AnnotatedFactory by Acelaya\ZsmAnnotatedServices\Factory\V2\AnnotatedFactory if you are using the v2 ServiceManager.

Cache

That looks cool, but processing annotations takes time. If you use this approach with several services, you will see your application's performance reduced.

That's why this library allows to use Doctrine\Cache adapters in order to cache the result of processing annotations.

First install the cache component.

composer require doctrine/cache

Then register another service which returns a Doctrine\Common\Cache\Cache instance with the key Acelaya\ZsmAnnotatedServices\Factory\AbstractAnnotatedFactory::CACHE_SERVICE (or just "Acelaya\ZsmAnnotatedServices\Cache", which is the value of the constant).

By doing this, your annotations will be processed and cached, improving performance for subsequent requests.

Dot notation for array or ArrayAccess services

When you need to inject just one part of a service which contains an array or ArrayAccess object, you can use the dot notation, where the first part is the service name and the rest of the parts are the keys to fetch from the array.

For example, imagine this services specification:

And this service with the @Inject annotation:

The injectable service is defined by config.mail.from. In this case, the AnnotatedFactory will assume that the service name is config, and that it contains an associative array or ArrayAccess object. Then, it will use the rest of the dotted parts as nested keys in that array, and finally get the last value and inject it in the service.


All versions of zsm-annotated-services with dependencies

PHP Build Version
Package Version
Requires php Version ^5.6 || ^7.0
zendframework/zend-servicemanager Version ^2.2 || ^3.0
doctrine/annotations Version ^1.2
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 acelaya/zsm-annotated-services contains the following files

Loading the files please wait ....