Generate Bruno API collections from Laravel routes.
This package analyzes your Laravel application's routes and generates a ready-to-use Bruno collection, complete with request bodies inferred from FormRequests, authentication configuration, environment files, and more.
You can install the package via composer:
composer require shahghasiadil/laravel-bruno-generator --devPublish the config file:
php artisan vendor:publish --tag=bruno-generator-configGenerate a collection:
php artisan bruno:generateDefault output:
bruno/collections/Laravel-API/
Open that folder in Bruno using Open Collection.
- One-command generation from Laravel routes
- FormRequest body inference
- Route filtering (middleware, prefix, include/exclude)
- Multiple organization strategies (
prefix,controller,tag,none) - Auth support (
none,bearer,basic,oauth2) - Multi-environment generation (
Local,Staging,Productionby default) - Optional docs, tests, and scripts generation
.bruand YAML output support- Deterministic, git-friendly generated files
Generate with default settings:
php artisan bruno:generateGenerate YAML output:
php artisan bruno:generate --format=yamlGenerate only API routes protected by Sanctum:
php artisan bruno:generate --api-only --middleware=auth:sanctumGenerate with docs and tests:
php artisan bruno:generate --with-docs --with-testsPreview without writing files:
php artisan bruno:generate --dry-runOverwrite existing output:
php artisan bruno:generate --forceClear generated collection:
php artisan bruno:clearClear a custom path:
php artisan bruno:clear path/to/collection --forcephp artisan bruno:generate \
--format=bru|yaml \
--output=path/to/output \
--name="My API" \
--api-only \
--prefix=api/v1 \
--exclude-prefix=admin \
--middleware=auth:sanctum \
--exclude-middleware=web \
--group-by=prefix|controller|tag|none \
--with-body-inference \
--with-tests \
--with-scripts \
--with-docs \
--force \
--dry-runYou can control most behavior through .env:
BRUNO_OUTPUT_PATH=bruno/collections
BRUNO_COLLECTION_NAME="Laravel API"
BRUNO_OUTPUT_FORMAT=bru
BRUNO_GROUP_BY=prefix
BRUNO_INFER_BODY=true
BRUNO_AUTH_MODE=bearer
APP_URL=http://localhost:8000
STAGING_URL=https://staging.example.com
PRODUCTION_URL=https://api.example.comAfter publishing, full options are available in config/bruno-generator.php.
output_path,collection_name,output_formatroute_discoveryfor include/exclude rulesorganizationfor grouping and sortingrequest_generationfor body/query/header behaviorauthfor mode and auth middleware detectionenvironmentsfor generated Bruno environmentsadvancedfor docs length, tests, scripts, YAML options, request settings
When enabled, request bodies are generated from your FormRequest rules.
Example FormRequest rules:
public function rules(): array
{
return [
'name' => 'required|string|max:255',
'email' => 'required|email',
'age' => 'integer|min:18',
'is_active' => 'boolean',
'tags' => 'array',
'tags.*' => 'string',
];
}Example generated body:
{
"name": "Name",
"email": "user@example.com",
"age": 18,
"is_active": true,
"tags": [""]
}Nested rules like user.name and user.email are also supported.
Both output formats are supported:
bru(default)yaml
Use command flag:
php artisan bruno:generate --format=yamlOr environment variable:
BRUNO_OUTPUT_FORMAT=yamlBy default, the package generates:
LocalStagingProduction
Each environment contains values like baseUrl and authToken and can be switched in Bruno.
You can add custom environments (for example Development, QA, UAT) in config/bruno-generator.php.
Typical output:
bruno/collections/Laravel-API/
bruno.json
environments/
Local.bru
Staging.bru
Production.bru
api/
...requests and folders...
- Use
--dry-runbefore first full generation - Keep route filters explicit in larger projects
- Commit generated collections to track API changes
- Keep environment URLs in
.env - Do not commit real auth tokens
Run tests:
composer testRun static analysis:
composer analyseFormat code:
composer formatPlease see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security-related issues, please email adil.shahghasi@gmail.com.
The MIT License (MIT). Please see License File for more information.