luky/slim

Library wrapper for PHP Slim framework

dev-master 2018-01-27 09:57 UTC

This package is auto-updated.

Last update: 2024-10-29 05:10:40 UTC


README

extensions:
	route: Luky\Slim\SlimExtension

route:
	default: MyUberApp\Route\DefaultRoute
	routes:
		- MyUberApp\Route\ArticleRoute
		- MyUberApp\Route\UserRoute

Example PHP Wrapper

<?php declare(strict_types = 1);

namespace MyUberApp\Route;

class ExampleRoute
{
	/** @var \ExampleFacade */
	private $exampleFacade;
	
	public function __construct(\ExampleFacade $exampleFacade)
	{
		$this->exampleFacade = $exampleFacade;
	}
	
	public function create(\Slim\App $app): void
	{
		$deps = $this;
		
		$app->group(
			'/article',
			function () use ($app, $deps) {
				
				$app->get(
					'/feed',
					function (\Slim\Http\Request $req, \Slim\Http\Response $res) use ($deps) {
						
						return $res->withJson(
							$deps->exampleFacade->feed()
						);
					}
				);
			}
		);
	}
}