PHPackages                             tox2ik/rka-slim-controller-json - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. tox2ik/rka-slim-controller-json

AbandonedArchivedLibrary[Parsing &amp; Serialization](/categories/parsing)

tox2ik/rka-slim-controller-json
===============================

Dynamically instantiated controller classes for Slim Framework

2.0.3(9y ago)028BSD-3-ClausePHPPHP 5.3.\*

Since Dec 15Pushed 9y ago1 watchersCompare

[ Source](https://github.com/tox2ik/rka-slim-controller)[ Packagist](https://packagist.org/packages/tox2ik/rka-slim-controller-json)[ Docs](https://github.com/tox2ik/rka-slim-controller)[ RSS](/packages/tox2ik-rka-slim-controller-json/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (10)Used By (0)

RKA Slim Controller
===================

[](#rka-slim-controller)

An extension to [Slim Framework](http://www.slimframework.com/) that allows you use to dynamically instantiated controllers with action methods wherever you would use a closure when routing.

The controller can optionally be loaded from Slim's DI container, allowing you to inject dependencies as required.

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

[](#installation)

```
composer require akrabat/rka-slim-controller

```

Usage
-----

[](#usage)

Use the string format `{controller class name}:{action method name}`wherever you would usually use a closure:

e.g.

```
$app = new \RKA\Slim();
$app->get('/hello:name', 'App\IndexController:home');

```

You can also register the controller with Slim's DI container:

```
$app = new \RKA\Slim();

$app->container->singleton('App\IndexController', function ($container) {
    // Retrieve any required dependencies from the container and
    // inject into the constructor of the controller

    return new \App\IndexController();
});

$app->get('/', 'App\IndexController:index');

```

Controller class methods
------------------------

[](#controller-class-methods)

*RKA Slim Controller* will call the controller's `setApp()`, `setRequest()`and `setResponse()` methods if they exist and populate appropriately. It will then call the controller's `init()`` method.

Hence, a typical controller may look like:

```
