2017 © Pedro Peláez
 

library slim3-controller

Implementation of controller for Slim Framework v3

image

orx0r/slim3-controller

Implementation of controller for Slim Framework v3

  • Sunday, May 8, 2016
  • by orx0r
  • Repository
  • 2 Watchers
  • 1 Stars
  • 75 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 1 % Grown

The README.md

slim3-controller

Latest Version on Packagist ![Software License][ico-license] Build Status ![Coverage Status][ico-scrutinizer] Quality Score ![Total Downloads][ico-downloads], (*1)

Implementation of controller for Slim Framework v3, (*2)

Install

Via Composer, (*3)

``` bash $ composer require orx0r/slim3-controller, (*4)


## Usage Please see [example](https://github.com/orx0r/slim3-controller/tree/master/example) how it works in action ``` php // in index.php $app->get('/hello/{name}', 'app\controllers\HelloController:index'); // in app/controllers/HelloController.php namespace app\controllers; use Orx0r\Slim\Controller\Controller; class HelloController extends Controller { public function actionIndex($name) { return $this->response->getBody()->write("Hello, $name"); } }

If you use one of template engine, you can use it in controller:, (*5)

// in index.php
$c = new \Slim\Container;

$c['view'] = function ($container) {
    $view = new \Slim\Views\Twig( __DIR__ . '/../templates');
    $view->addExtension(new \Slim\Views\TwigExtension(
        $container['router'],
        $container['request']->getUri()
    ));

    return $view;
};

$app->get('/hello/{name}', 'app\controllers\HelloController:index');

// in app/controllers/HelloController.php
public function actionIndex($name)
{
    return $this->render('hello/index.html', ['name' => $name]);
}

In small Slim app you can use controllerNamespace for resolving all your controllers in same namespace by specifying only controller name. It works without breaking your old code, (*6)

// register CallableResolver. pass second parameter as controllerNamespace
$c['callableResolver'] = function ($container) {
    return new CallableResolver($container, 'app\controllers');
};

$app->get('/hello/{name}', 'HelloController:index');

Testing

bash $ composer test, (*7)

Contributing

Please see CONTRIBUTING, (*8)

License

The MIT License (MIT). Please see License File for more information., (*9)

The Versions

08/05 2016

dev-master

9999999-dev https://github.com/orx0r/slim3-controller

Implementation of controller for Slim Framework v3

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar orx0r

mvc slim controller slim3

08/05 2016

0.1.2

0.1.2.0 https://github.com/orx0r/slim3-controller

Implementation of controller for Slim Framework v3

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar orx0r

mvc slim controller slim3

28/04 2016

0.1.1

0.1.1.0 https://github.com/orx0r/slim3-controller

Implementation of controller for Slim Framework v3

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar orx0r

mvc slim controller slim3