Here https://github.com/zendframework/zend-mvc/blob/master/src/Application.php#L64 is the mention of ‘MiddlewareListener’. Can somebody give me some links on tutorials with examples of using zend-stratigility and ‘MiddlewareListener’ and how to integrate it into project based on zend-mvc and apigility? It would be great to see simple authentication middleware with such body:
if(!$authenticated){
$redirectTo('/login');
}
Have you seen the related section in the documentation of zend-mvc: Dispatching PSR-7 Middleware - zend-mvc - Zend Framework Docs
Yes, I have but I don’t understand what is:
$app = new MiddlewarePipe();
$server = Server::createServer([$app, 'handle'], $_SERVER, $_GET, $_POST, $_COOKIE, $_FILES);
// Landing page
$app->pipe(middleware(function ($req, $handler) {
and what to do with that and how to integrate it into zend-mvc and apigility.
All this is not needed, because it’s already included in zend-mvc. Follow the description in documentation; create a middleware and add the correct routing configuration.
It doesn’t seems to be so obvious. I have found this skeleton https://github.com/ezimuel/zend-stratigility-skeleton but it isn’t what I need. It looks like as standalone project without integration into zend-mvc.