29
AugScribe helps you generate API documentation for humans from your Laravel/Lumen/Dingo codebase. You can see a live example here.
First, you’ve to add the package via Composer:
composer require --dev knuckleswtf/scribe
Publish the config file by running:
php artisan vendor:publish --tag=scribe-config
This will create a scribe.php
file in your config folder.
1. Pick a type
The type key tells Scribe the type of docs setup you want. There are two options:
2. Choose your routes
The second thing you’ll need to do is tell Scribe what routes you want to document (the routes
key). By default, it looks similar to this:
'routes' => [
[
'match' => [
'domains' => ['*'],
'prefixes' => ['api/*'],
'versions' => ['v1'],
],
'include' => [
// 'users.index', 'healthcheck*'
],
'exclude' => [
// '/health', 'admin.*'
],
],
],
The important key here is the prefixes. Set it to a path matching your API routes. For instance, the default config ([“api/"]
) will match any endpoints that start with <
. You can set it to your-app-url
>/api/["”]
to match all endpoints.
Do a test run
Now, let’s do a test run. Run the command to generate your docs.
php artisan scribe:generate
Visit your newly generated docs:
public/
folder and open it in your browser./docs
.Add general information about your API
Here are some things you can customize with Scribe:
Add information to your routes
Scribe tries to figure out information about your routes, but you can improve it by adding more information. Here’s some information you can enrich:
Generate and publish
After making changes as needed, you can run php artisan scribe:generate
as many times as you want.
You’re good to go when you’re happy with how your documentation looks. You can add the generated documentation to your version control and deploy it as normal, and your users will be able to access it as you’ve configured it.
Don’t like how the template looks? Want to change how things are organized, or add a custom language for the examples? Thinking of custom ways to extract more information about your routes? Check out the complete documentation for customization options.
We are highly results-driven experts having experience in the grounds of Laravel web application development, CRM software, SAAS applications, and eCommerce web apps. So If you want to develop a custom web app you can contact us or Start a project with us.
Published at : 29-08-2022
I am a highly results-driven professional with 12+ years of collective experience in the grounds of web application development especially in laravel, native android application development in java, and desktop application development in the dot net framework. Now managing a team of expert developers at Codebrisk.
Launch project