swagger-codegen icon indicating copy to clipboard operation
swagger-codegen copied to clipboard

[php-symfony][question] Generated code contains no entrypoint?

Open mfurlend opened this issue 8 years ago • 1 comments

When I generate a server stub using the php-silex preset I get an index.php. If I google "silex .htaccess" I can easily find the mod_rewrite directives to get it working. However, when I generate code using the php-symfony preset I cannot find the entrypoint. I attempted to combine the php-silex and php-symfony generated codebases (since silex is a symfony project) like so:

(index.php):
use Swagger\Server\Controller\GetTypesListController;
$app->GET('/image/list/types', function (Application $app, Request $request) {
    $tlc = new GetTypesListController();
    $response = $tlc->getTypeListAction($request);
    return $response;//new Response('How about implementing getTypeList as a GET method ?');
});

However, then I get errors like:

"Fatal error: Uncaught Error: Call to a member function getApiHandler() on null"

I modified the getApiHandler function of my generated GetTypesListController to instantiate the apiServer variable:

public function getApiHandler()
{
    if (!isset($this->apiServer)){
        $this->apiServer = new \Swagger\Server\Api\ApiServer();
    }
    return $this->apiServer->getApiHandler('getTypesList');
}

but this just gave me another error:

Undefined property: Swagger\Server\Controller\GetTypesListController::$container

(referencing SymfonyBundle-php/Controller/Controller.php on line 149)

I am obviously doing something wrong. I would really appreciate being pointed in the right direction.

mfurlend avatar Jul 06 '18 18:07 mfurlend

The symfony generator does not create a project with entry point. It creates a symfony bundle that you can use in a project. In the bundle there is a readme with instructions.

hhofstaetter avatar Jan 20 '19 09:01 hhofstaetter