Skip to content
This repository has been archived by the owner on May 3, 2020. It is now read-only.

Latest commit

 

History

History
52 lines (35 loc) · 963 Bytes

README.md

File metadata and controls

52 lines (35 loc) · 963 Bytes

Slim Controllers

Slim Controllers is an extremely lightweight framework to provide controllers for Slim 4.

Installation

composer require icosillion/slim-controllers

Usage

Use Slim's groups to group your controller actions together in your main Slim file.

<?php

use Slim\App;

$app = new App();

$app->group('/', function () use ($app) {
    $controller = new RootController($app);

    $app->get('', $controller('index'));
});

$app->run();

Extend your controller from the Controller class.

<?php

use Icosillion\SlimControllers\Controller;
use Slim\Http\Request;
use Slim\Http\Response;

class RootController extends Controller
{
    public function index(Request $request, Response $response, array $args)
    {
        $response->getBody()->write('Hello World!');

        return $response;
    }
}

License

This project is licensed under the MIT license. A copy of this is available in the LICENSE file.