项目作者: middlewares

项目描述 :
Collection of PSR-15 middlewares
高级语言:
项目地址: git://github.com/middlewares/psr15-middlewares.git
创建时间: 2016-10-10T16:36:47Z
项目社区:https://github.com/middlewares/psr15-middlewares

开源协议:MIT License

下载


logo

psr15-middlewares

Collection of PSR-15 middlewares

Requirements

Usage example

  1. use Zend\Diactoros\ServerRequestFactory;
  2. use Middlewares\Utils\Dispatcher;
  3. use Middlewares;
  4. $dispatcher = new Dispatcher([
  5. //Handle errors
  6. (new Middlewares\ErrorHandler())
  7. ->catchExceptions(true),
  8. //Log the request
  9. new Middlewares\AccessLog($app->get('logger')),
  10. //Calculate the response time
  11. new Middlewares\ResponseTime(),
  12. //Removes the trailing slash
  13. new Middlewares\TrailingSlash(false),
  14. //Insert the UUID
  15. new Middlewares\Uuid(),
  16. //Disable the search engine robots
  17. new Middlewares\Robots(false),
  18. //Compress the response to gzip
  19. new Middlewares\GzipEncoder(),
  20. //Minify the html
  21. new Middlewares\HtmlMinifier(),
  22. //Override the method using X-Http-Method-Override header
  23. new Middlewares\MethodOverride(),
  24. //Parse the json payload
  25. new Middlewares\JsonPayload(),
  26. //Parse the urlencoded payload
  27. new Middlewares\UrlEncodePayload(),
  28. //Save the client ip in the '_ip' attribute
  29. (new Middlewares\ClientIp())
  30. ->attribute('_ip'),
  31. //Allow only some ips
  32. (new Middlewares\Firewall(['127.0.0.*']))
  33. ->ipAttribute('_ip'),
  34. //Add cache expiration headers
  35. new Middlewares\Expires(),
  36. //Add the php debugbar
  37. new Middlewares\Debugbar(),
  38. //Negotiate the content-type
  39. new Middlewares\ContentType(),
  40. //Negotiate the language
  41. new Middlewares\ContentLanguage(['gl', 'es', 'en']),
  42. //Handle the routes with fast-route
  43. new Middlewares\FastRoute($app->get('dispatcher')),
  44. //Create and save a session in '_session' attribute
  45. (new Middlewares\AuraSession())
  46. ->attribute('_session'),
  47. //Handle the route
  48. new Middlewares\RequestHandler(),
  49. ]);
  50. $response = $dispatcher->dispatch(ServerRequestFactory::fromGlobals());

List of all available middlewares

Authentication

Client info

Develop utils

Optimization

Routers

Security

Session

URLs

Others

Contributing

Use the package repository of each component to notify any issue or pull request related with it, and use this repository for generical questions, new middlewares discussions, etc.

If you want to contribute with new middlewares, you can take a look to these ideas. There’s also a skeleton that you can use for quick start.

See CONTRIBUTING for contributing details.

Download the logo from the art directory.


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