Generate API Documentation for Laravel with Scramble

Packages

August 10th, 2023

Generate API Documentation for Laravel with Scramble

Scramble is a package for Laravel that generates API documentation without requiring you to write PHPDoc annotations manually. The UI utilizes Spotlight Elements to provide interactive API Docs with embeddable React or Web Components, powered by OpenAPI and Markdown.

The main motto of [Scramble] is to generate as much API documentation automatically as possible. This allows you to focus on code and avoid annotating every possible param/field as it may result in outdated documentation. By generating docs automatically from the code your API will always have up-to-date documentation you can trust.

After installing Scramble in your Laravel API project, you will get two new routes: /docs/api to view our API documentation, and /docs/api.json which is an Open API document in JSON format used to describe your API.

Scramble relies on static analysis and Laravel conventions to generate as much documentation as possible for you, with the ability to supplement the automatic documentation with annotations. Part of what Scramble does is check form requests or a call to validate() to document required parameters.

Other neat features include:

  • Configurable route resolution using the Scramble::routes() method
  • Documentation authorization gate
  • Server configuration
  • Document security scheme using common conventions like JWT, Basic, OAuth2, etc.
  • Extensions API
  • And more

To get started with Scramble, you can check out the Getting started documentation, which includes installation, setup, and more. You can learn more about this package, get full installation instructions, and view the source code on GitHub.

Filed in:

Paul Redmond

Full stack web developer. Author of Lumen Programming Guide and Docker for PHP Developers.