Skip to content

Commit

Permalink
updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed Feb 27, 2017
1 parent 689e7da commit 4433959
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Middleware to use [FastRoute](https://github.com/nikic/FastRoute).
* PHP >= 5.6
* A [PSR-7](https://packagist.org/providers/psr/http-message-implementation) http mesage implementation ([Diactoros](https://github.com/zendframework/zend-diactoros), [Guzzle](https://github.com/guzzle/psr7), [Slim](https://github.com/slimphp/Slim), etc...)
* A [PSR-15 middleware dispatcher](https://github.com/middlewares/awesome-psr15-middlewares#dispatcher)
* Optionally, a [PSR-11](https://github.com/php-fig/container) container to resolve the route handlers

## Installation

Expand Down Expand Up @@ -56,18 +57,17 @@ $response = $dispatcher->dispatch(new ServerRequest('/hello/world'));
* If the string is the name of a existing class (like: `Namespace\Class`) and contains the method `__invoke`, create a instance and execute that method.
* Otherwise, treat it as a callable.

If you want to change this behaviour, use a container implementing the [container-interop](https://github.com/container-interop/container-interop) to return the route callable.

If you want to change this behaviour, use a container implementing the [PSR-11 spec](https://github.com/php-fig/container) to return the route callable.

## Options

#### `__construct(FastRoute\Dispatcher $dispatcher)`

The dispatcher instance to use.

#### `resolver(Interop\Container\ContainerInterface $resolver)`
#### `resolver(Psr\Container\ContainerInterface $resolver)`

To use a container implementing [container-interop](https://github.com/container-interop/container-interop) to resolve the route handlers.
To use a container implementing [PSR-11 interface](https://github.com/php-fig/container) to resolve the route handlers.

#### `arguments(...$args)`

Expand Down
8 changes: 5 additions & 3 deletions src/FastRoute.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Middlewares;

use Middlewares\Utils\Factory;
use Middlewares\Utils\CallableHandler;
use Middlewares\Utils\CallableResolver\CallableResolverInterface;
use Middlewares\Utils\CallableResolver\ContainerResolver;
use Middlewares\Utils\CallableResolver\ReflectionResolver;
Expand Down Expand Up @@ -78,11 +80,11 @@ public function process(ServerRequestInterface $request, DelegateInterface $dele
$route = $this->router->dispatch($request->getMethod(), $request->getUri()->getPath());

if ($route[0] === Dispatcher::NOT_FOUND) {
return Utils\Factory::createResponse(404);
return Factory::createResponse(404);
}

if ($route[0] === Dispatcher::METHOD_NOT_ALLOWED) {
return Utils\Factory::createResponse(405);
return Factory::createResponse(405);
}

foreach ($route[2] as $name => $value) {
Expand All @@ -93,7 +95,7 @@ public function process(ServerRequestInterface $request, DelegateInterface $dele

$callable = $this->getResolver()->resolve($route[1], $arguments);

return Utils\CallableHandler::execute($callable, $arguments);
return CallableHandler::execute($callable, $arguments);
}

/**
Expand Down

0 comments on commit 4433959

Please sign in to comment.