To make things really easy I’ve packaged Swagger UI as a ZF2 module and submitted it to packagist. Just add
[code language="php"]"kbrabrand/zf2-swagger-ui": "dev-master"[/code]
…to your composer.json file and do a “composer update” and enable the module in your ZF2 application by adding “SwaggerUI” to the modules array. The last thing to do then is to add a symlink for the public assets needed for the SwaggerUI documentation viewer;
[code language="shell"]cd [ZF2-app-root]/public && ln -s ../vendor/kbrabrand/zf2-swagger-ui/public swagger-ui[/code]
That’s it! Given that you haven’t changed the route for SwaggerModule (the module we added in the previous blog post to utilize Swagger-PHP in a ZF2 app) the nice Swagger UI docs should now be visible at [ZF2-app-root]/api/swagger.
If your Swagger JSON files is located somewhere else than the default location (/api/docs), you will need to copy the swagger-ui.global.php.dist into you config/autoloads folder, remove the dist extension and set the correct path or URL to where you’ve put them.
Once again: happy documenting!