This post is for those who are working on Laravel Lumen projects with Swagger UI which runs using the PHP built-in web server.
If you are using the DarkaOnline/SwaggerLume library to generate the Swagger UI, you will probably notice that the Swagger UI is empty. And if you inspect the front-end error in the Swagger UI web page, you will see that it will display the error:
In the screenshot, you will find errors such as,
SwaggerUIBundle is not defined
at window.onload
which indicates that the Swagger UI asset files (css, javascript etc) cannot be found.
The root cause of the error is due to running the built-in PHP web-server with the following command:
php -S localhost:8000 -t public
To resolve this issue, you will need to run the web server with the following command instead:
php -S localhost:8000 public/index.php
By specifying the document root as 'public/index.php' with the above command, laravel lumen is able to find the swagger UI assets.