PHPackages                             spiffy/spiffy-config - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. spiffy/spiffy-config

AbandonedLibrary[Framework](/categories/framework)

spiffy/spiffy-config
====================

ZF2 module that provides route annotations directly in controllers.

1.0.2(11y ago)826.0k1BSD-3-ClausePHPPHP &gt;=5.3.3

Since Jul 2Pushed 11y ago1 watchersCompare

[ Source](https://github.com/spiffyjr/spiffy-config)[ Packagist](https://packagist.org/packages/spiffy/spiffy-config)[ Docs](http://www.github.com/spiffyjr/spiffy-config.git)[ RSS](/packages/spiffy-spiffy-config/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (2)Dependencies (13)Versions (7)Used By (0)

SpiffyConfig Module
===================

[](#spiffyconfig-module)

SpiffyConfig is a module designed to speed up configuration.

Installation
------------

[](#installation)

Installation of SpiffyConfig uses composer. For composer documentation, please refer to [getcomposer.org](http://getcomposer.org/).

```
php composer.phar require spiffy/spiffy-config:dev-master
```

Then add `SpiffyConfig` to your `config/application.config.php`

Installation without composer is not officially supported, and requires you to install and autoload the dependencies specified in the `composer.json`.

Finally, copy `config/spiffyconfig.global.php.dist` to `autoload/spiffyconfig.global.php` directory. This will setup the Application module out of the box.

Resolvers
---------

[](#resolvers)

Resolvers pass information to builders so that the builders know what to work on.

- File: resolves files using Symfony's file finder.

Builders
--------

[](#builders)

Builders take information from the resolvers and build configurations based on that information.

- RouteBuilder: reads route annotations and builds configuration via events.
- ServiceBuilder: reads service annotations and builds configuration via events.
- TemplateBuilder: takes files from the file resolver and builds a template\_map from them.

Supported Annotations
---------------------

[](#supported-annotations)

Below is a list of currently supported annotations. This list will be updated as more annotations are supported. In order to use the annotations you **must import them first**. Do this by putting the following at the top of your code,

```
use SpiffyConfig\Annotation as Config;
```

This will let you use SpiffyConfig's annotations using `@Config` in your docblock.

### Service

[](#service)

Service annotations are found in the `SpiffyConfig\Annotation\Service` namespace and handle setting up invokables and factories on various service managers.

Properties:

- key: the key to use when defining the configuration (default: service\_manager). You can use a pipe "|" to nest the key in the configuration array, e.g., my|nested would set the services as: `php array( 'my' => array( 'nested' => array( // service configuration would go here ) ) ) `
- shared: set the service as shared or not (default: null)
- type: this is set by using the `SpiffyConfig\Annotation\Service\Factory` or `SpiffyConfig\Annotation\Service\Invokable` annotation (default: factories/invokables repsectively)
- name: the name to use for the service. If no name is specified the FQCN is used.

There are several annotations that extend the service annotations and predefine the `key` property to save you the extra step. Each of these have a Factory and Invokable annotation available.

Service Annotations:

- `SpiffyConfig\Annotation\Controller`: key set to `controllers`
- `SpiffyConfig\Annotation\Form`: key set to `form_elements`
- `SpiffyConfig\Annotation\Hydrator`: key set to `hydrators`
- `SpiffyConfig\Annotation\RouteManager`: key set to `route_manager`

```
namespace Application\Service;

use SpiffyConfig\Annotation\Service;

/**
 * This annotation will set the Mailer service using the service_manager key
 * under the service name "Application\Service\Mailer". I could specify a name
 * if I don't want to use the FQCN.
 *
 * @Service\Invokable
 */
class Mailer implements ServiceLocatorAwareInterface
{
    // ... implementation ...
}
```

```
namespace Application\Service;

use SpiffyConfig\Annotation\Service;

/**
 * This annotation will set the Mailer service using the service_manager key
 * under the service name "mailer" and being built from the "Application\Service\MailerFactory"
 * factory.
 *
 * @Service\Factory("Application\Service\MailerFactory", name="mailer")
 */
class Mailer implements ServiceLocatorAwareInterface
{
    // ... implementation ...
}
```

### Route

[](#route)

Route annotations handle setting up routes directly in your controllers. They can be set at the class level or the method level. If set on the class level you must specify the action that the route pertains to. If set directly on the method then the action is set for you.

Currently, the following routes are available:

- Generic: used to setup any type of route you want. Nothing is managed directly.
- Literal: setup literal routes
- Regex: setup regex routes.
- Segment: setup segment routes.

Example:

```
