PHP Classes

File: Examples/HelloWorld/public/index.php

Recommend this page to a friend!
  Classes of Virgilio lino   PHP OpenAPI Dispatcher   Examples/HelloWorld/public/index.php   Download  
File: Examples/HelloWorld/public/index.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP OpenAPI 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: 6 years 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();