redreams/slim-annotation-based

Slim application with support annotation based controllers

2.1.2 2018-08-07 18:11 UTC

This package is not auto-updated.

Last update: 2024-11-18 07:25:23 UTC


README

Latest Version on Packagist Software License Total Downloads

Coverage Status Sensiolabs_Medal Quality Score

slim-annotation-based composer package

Install

Via Composer

$ composer require redreams/slim-annotation-based

Usage

use Redreams\Slim\App;
//front controller (index.php)
$config = [];//defaul slim config
$config['settings']['routerCacheDir'] = './dirForDoctrineAnnotationReader';//optional
$app = new App('./controllersDir', $config);

// controllersDir/IndexController.php
use Redreams\Slim\AbstractController;
use Redreams\Slim\Annotation\Route;

/**
 * @Route("/")
 */
class IndexController extends AbstractController
{
    /**
     * @Route("/")
     * @param Request  $request
     * @param Response $response
     *
     * @return Response
     */
    public function indexAction(Request $request, Response $response): Response
    {
        return $response->write('index:index');
    }

    /**
     * @Route("/test")
     * @param Request  $request
     * @param Response $response
     *
     * @return Response
     */
    public function testAction(Request $request, Response $response): Response
    {
        return $response->write('index:test');
    }

    /**
     * @Route("/getonly", methods={"GET"})
     * @param Request  $request
     * @param Response $response
     *
     * @return Response
     */
    public function getOnlyAction(Request $request, Response $response): Response
    {
        return $response->write('index:getOnly');
    }

    /**
     * @Route("/named", name="namedAction")
     * @param Request  $request
     * @param Response $response
     *
     * @return Response
     */
    public function namedAction(Request $request, Response $response): Response
    {
        return $response->write('index:named');
    }
}

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email dev@gennadyx.tech instead of using the issue tracker.

Credits

License

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