Scramble 0.11.0 is here! Laravel Data support, schema enforcement and more
Learn more

Installation & setup

On this page
Scramble PRO
Comprehensive API documentation generation for Spatie’s Laravel Data and Laravel Query Builder.
Are you a visual learner?
Get most out of Scramble with in-depth screencasts.

Scramble requires:

  • PHP 8.1 or higher
  • Laravel 10.x or higher

You can install Scramble via composer:

Terminal window
composer require dedoc/scramble

When Scramble is installed, 2 routes are added to your application:

  • /docs/api - UI viewer for your documentation
  • /docs/api.json - Open API document in JSON format describing your API.

And that’s it! You can now visit /docs/api to see your API documentation.

By default, these routes are available only in local environment. You can change this behavior by defining viewApiDocs gate.

Publishing config

Optionally, you can publish the package’s config file:

Terminal window
php artisan vendor:publish --provider="Dedoc\Scramble\ScrambleServiceProvider" --tag="scramble-config"

This will allow you to customize API routes resolution and OpenAPI document’s details.

The content of scramble config:

<?php
use Dedoc\Scramble\Http\Middleware\RestrictedDocsAccess;
return [
/*
* Your API path. By default, all routes starting with this path will be added to the docs.
* If you need to change this behavior, you can add your custom routes resolver using `Scramble::routes()`.
*/
'api_path' => 'api',
/*
* Your API domain. By default, app domain is used. This is also a part of the default API routes
* matcher, so when implementing your own, make sure you use this config if needed.
*/
'api_domain' => null,
'info' => [
/*
* API version.
*/
'version' => env('API_VERSION', '0.0.1'),
/*
* Description rendered on the home page of the API documentation (`/docs/api`).
*/
'description' => '',
],
/*
* The list of servers of the API. By default (when `null`), server URL will be created from
* `scramble.api_path` and `scramble.api_domain` config variables. When providing an array, you
* will need to specify the local server URL manually (if needed).
*
* Example of non-default config (final URLs are generated using Laravel `url` helper):
*
* ```php
* 'servers' => [
* 'Live' => 'api',
* 'Prod' => 'https://scramble.dedoc.co/api',
* ],
* ```
*/
'servers' => null,
'middleware' => [
'web',
RestrictedDocsAccess::class,
],
'extensions' => [],
];
Scramble PRO
Comprehensive API documentation generation for Spatie’s Laravel Data and Laravel Query Builder.