PHP Classes
elePHPant
Icontem

File: Examples/HelloWorld/public/index.php

Recommend this page to a friend!
  Classes of Virgilio lino  >  Swagger Slim Dispatcher  >  Examples/HelloWorld/public/index.php  >  Download  
File: Examples/HelloWorld/public/index.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Swagger Slim Dispatcher
Dispatch requests to controllers defined in files
Author: By
Last change: hello world improvement
complaining to open api specification V3. swagger is always renames to openApi
Date: 22 days ago
Size: 743 bytes
 

Contents

Class file image Download
<?php
require 'vendor/autoload.php';
$app = new \Slim\App;
$container = $app->getContainer();
//your command Handlers need to be injected by operationId
$container['HelloWorld'] = function () {
    return new \
HelloWorld\CommandHandlers\HelloWorld();
};
$openApiFile = 'routes.json';
$openApiConfigParser = Dispatcher\OpenApi\ParserFactory::parserFor($openApiFile);
$openApiConfig = $openApiConfigParser->parse($openApiFile);
$applicationBridge = new \Sab\Application\Bridge\SlimBridge($app);
$routesInjector = new \Dispatcher\OpenApi\Route\DefaultRouteInjector();
$openApiDispatcher = new \Dispatcher\OpenApi\OpenApiDispatcher($routesInjector);
$openApiDispatcher->InjectRoutesFromConfig($applicationBridge, $openApiConfig);

$app->run();