Search code examples
silex

swagger.json uri mapping does not work in Silex app


I am developing a REST api using PHP and Silex and Swagger. In a local development environment I am trying to map the uri http://localhost:8888/swagger.json to the swagger spec. However, the silex routing mechanism in a local dev mode does not seem to like uri's that end with ".json". I can get this to work when I deploy the application to an http server, but not in local dev mode. Does anyone know if this is a config issue in Silex? Thanks.


Solution

  • In case anyone wants to refer to this later. I found a solution. To get this to work in my project, which is based on the Silex skeleton project (https://silex.symfony.com/download). The skeleton project includes web/index_dev.php. I created a task in my composer file that runs the php local/dev server for the project using that file. The task looks like this:

    php -S localhost:8888 -t web /web/index_dev.php