2017 © Pedro Peláez
 

library setter-strategy

Alternative dispatch strategy for slim 3

image

geggleto/setter-strategy

Alternative dispatch strategy for slim 3

  • Tuesday, March 8, 2016
  • by geggleto
  • Repository
  • 1 Watchers
  • 0 Stars
  • 12 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Build Status, (*1)

setter-injection-strategy

This package is intended to replace the default Invocation handler in Slim. This strategy forces controllers to implement SetterInjectionReceiver which tells Slim to set the Response, Request, and Arg instead of passing it through the method signature. This saves space on all of your action methods in your controller., (*2)

In short it will turn this., (*3)

class abcController {
  //...
  public function myAction (Request $request, Response $response, $args = []) {
    //..
  }
  //...
}

Into This., (*4)

class abcController implements SetterInjectionReceiver {
  //.. Implement and store the Objects somewhere up here.
  //...
  public function myAction () {
    //..  This is now much more Slim 2 style
  }
  //...
}

Or this if you have arguments, (*5)

class abcController implements SetterInjectionReceiver {
  //.. Implement and store the Objects somewhere up here.
  //...
  public function myAction ($arg1, $arg2, $arg3) {
    //..  This is now much more Slim 2 style
  }
  //...
}

Install

This package is available via Composer. composer install geggleto/setter-strategy, (*6)

Usage

There are some configuration changes you will need to make in your Slim application. If you only wish to use SetterInjection on some of your callables, It will default back to using the RequestResponseArgs style if your controller does not implement the Receiver Interface, (*7)

// Setup the Strategy in the container by adding a factory method like below.
  $container['foundHandler'] = function ($c) {
      return new SetterInjectionStrategy();
  };

The Versions

08/03 2016

dev-master

9999999-dev

Alternative dispatch strategy for slim 3

  Sources   Download

MIT

The Requires

 

The Development Requires

08/03 2016

0.0.3

0.0.3.0

Alternative dispatch strategy for slim 3

  Sources   Download

MIT

The Requires

 

The Development Requires

04/03 2016

0.0.2

0.0.2.0

Alternative dispatch strategy for slim 3

  Sources   Download

MIT

The Requires

 

04/03 2016

0.0.1

0.0.1.0

Alternative dispatch strategy for slim 3

  Sources   Download

MIT

The Requires