PHPackages                             shahghasiadil/laravel-bruno-generator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. shahghasiadil/laravel-bruno-generator

ActiveLibrary[Testing &amp; Quality](/categories/testing)

shahghasiadil/laravel-bruno-generator
=====================================

Generate Bruno API collections from Laravel routes with automatic request body inference and environment support

v1.0.2(1mo ago)26278↑33.3%2MITPHPPHP ^8.3CI passing

Since Dec 20Pushed 3mo agoCompare

[ Source](https://github.com/shahghasiadil/laravel-bruno-generator)[ Packagist](https://packagist.org/packages/shahghasiadil/laravel-bruno-generator)[ Docs](https://github.com/shahghasiadil/laravel-bruno-generator)[ RSS](/packages/shahghasiadil-laravel-bruno-generator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (35)Versions (7)Used By (0)

Laravel Bruno Generator
=======================

[](#laravel-bruno-generator)

[![Latest Version on Packagist](https://camo.githubusercontent.com/218244f97fe00f6fd0a6f7711507089633a6fc43dfb646ea33010e6adf317e88/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7368616867686173696164696c2f6c61726176656c2d6272756e6f2d67656e657261746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/shahghasiadil/laravel-bruno-generator)[![Total Downloads](https://camo.githubusercontent.com/28158dcd6a626d86122f774976af7e34d920d198988a3c2efec8ace917517eef/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7368616867686173696164696c2f6c61726176656c2d6272756e6f2d67656e657261746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/shahghasiadil/laravel-bruno-generator)

**Automatically generate [Bruno](https://www.usebruno.com/) API collections from your 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.

Features
--------

[](#features)

- 🚀 **One-Command Generation** - Generate complete Bruno collections instantly
- 📝 **FormRequest Integration** - Automatically infer request bodies from Laravel FormRequests
- 🗂️ **Smart Organization** - Group requests by prefix, controller, or tags
- 🔐 **Auth Support** - Bearer, Basic, and OAuth2 authentication
- 🌍 **Multi-Environment** - Generate Local, Staging, and Production environments
- 📚 **PHPDoc Extraction** - Include controller method documentation
- ✅ **Test Generation** - Optional test block generation
- 🎯 **Powerful Filtering** - Filter by middleware, prefix, route name patterns
- 💾 **Git-Friendly** - Deterministic output perfect for version control
- 🛡️ **Type-Safe** - Full PHP 8.1+ strict types throughout

Requirements
------------

[](#requirements)

- PHP 8.1, 8.2, or 8.3
- Laravel 10, 11, or 12

Environment Variables
---------------------

[](#environment-variables)

The package supports several environment variables for quick configuration without modifying the config file:

VariableDescriptionDefault`BRUNO_OUTPUT_PATH`Output directory for Bruno collections`bruno/collections``BRUNO_COLLECTION_NAME`Name of the generated collection`Laravel API``BRUNO_GROUP_BY`Grouping strategy (prefix/controller/tag/none)`prefix``BRUNO_INFER_BODY`Enable FormRequest body inference`true``BRUNO_AUTH_MODE`Authentication mode (none/bearer/basic/oauth2)`bearer``APP_URL`Local environment base URL`http://localhost:8000``STAGING_URL`Staging environment base URL`https://staging.example.com``PRODUCTION_URL`Production environment base URL`https://api.example.com`### Using Environment Variables

[](#using-environment-variables)

Add these to your `.env` file to customize the generation behavior:

```
# Bruno Generator Settings
BRUNO_OUTPUT_PATH=bruno/collections
BRUNO_COLLECTION_NAME="My Project API"
BRUNO_GROUP_BY=controller
BRUNO_INFER_BODY=true
BRUNO_AUTH_MODE=bearer

# Environment URLs
APP_URL=http://localhost:8000
STAGING_URL=https://staging.myapp.com
PRODUCTION_URL=https://api.myapp.com
```

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require shahghasiadil/laravel-bruno-generator --dev
```

Publish the configuration file:

```
php artisan vendor:publish --tag=bruno-generator-config
```

Quick Start
-----------

[](#quick-start)

Generate a Bruno collection from your API routes:

```
php artisan bruno:generate
```

The collection will be generated in `bruno/collections/Laravel-API/` by default.

### Open in Bruno

[](#open-in-bruno)

1. Open Bruno application
2. Click "Open Collection"
3. Navigate to the generated folder
4. Start testing your API!

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

Generate with default settings:

```
php artisan bruno:generate
```

### Command Options

[](#command-options)

```
php artisan bruno:generate
    --output=path/to/output      # Custom output directory
    --name="My API"              # Collection name
    --api-only                   # Include only API routes
    --prefix=api/v1              # Filter by route prefix
    --middleware=auth:sanctum    # Filter by middleware
    --group-by=controller        # Group by: prefix|controller|tag|none
    --with-body-inference        # Enable FormRequest parsing
    --with-tests                 # Generate test blocks
    --with-docs                  # Include PHPDoc documentation
    --force                      # Overwrite existing collection
    --dry-run                    # Preview without writing files
```

### Examples

[](#examples)

**Generate only authenticated API routes:**

```
php artisan bruno:generate --api-only --middleware=auth:sanctum
```

**Generate with FormRequest body inference:**

```
php artisan bruno:generate --with-body-inference
```

**Group by controller with tests:**

```
php artisan bruno:generate --group-by=controller --with-tests
```

**Dry run to preview:**

```
php artisan bruno:generate --dry-run
```

**Clear generated collection:**

```
php artisan bruno:clear
```

Configuration
-------------

[](#configuration)

The configuration file provides extensive customization options:

### Route Discovery &amp; Filtering

[](#route-discovery--filtering)

```
'route_discovery' => [
    'auto_detect_api' => true,

    'include_middleware' => ['api'],
    'exclude_middleware' => ['web'],

    'include_prefixes' => [],
    'exclude_prefixes' => ['telescope', 'horizon'],

    'include_names' => [],
    'exclude_names' => ['/^debugbar\./'],

    'exclude_fallback' => true,
],
```

### Collection Organization

[](#collection-organization)

```
'organization' => [
    'group_by' => 'prefix', // prefix|controller|tag|none
    'folder_depth' => 2,
    'sort_by' => 'uri',     // uri|method|name|none
    'sort_direction' => 'asc',
],
```

### Request Generation

[](#request-generation)

```
'request_generation' => [
    'infer_body_from_form_request' => true,
    'generate_example_values' => true,
    'parameterize_route_params' => true,
    'generate_query_params' => true,
],
```

### Authentication

[](#authentication)

```
'auth' => [
    'mode' => 'bearer',  // none|bearer|basic|oauth2
    'bearer_token_var' => 'authToken',
    'include_auth' => true,
    'auth_middleware' => ['auth:sanctum', 'auth:api'],
],
```

### Environments

[](#environments)

Configure multiple environments with different base URLs and authentication tokens:

```
'environments' => [
    'Local' => [
        'baseUrl' => env('APP_URL', 'http://localhost:8000'),
        'authToken' => '',
    ],
    'Staging' => [
        'baseUrl' => env('STAGING_URL', 'https://staging.example.com'),
        'authToken' => '',
    ],
    'Production' => [
        'baseUrl' => env('PRODUCTION_URL', 'https://api.example.com'),
        'authToken' => '',
    ],
],
```

Each environment generates a separate `.bru` file in the `environments/` folder, making it easy to switch between different environments in Bruno.

FormRequest Body Inference
--------------------------

[](#formrequest-body-inference)

The package can automatically generate request bodies from your Laravel FormRequests:

```
// app/Http/Requests/UpdateUserRequest.php
class UpdateUserRequest extends FormRequest
{
    public function rules(): array
    {
        return [
            'name' => 'required|string|max:255',
            'email' => 'required|email',
            'age' => 'integer|min:18',
            'is_active' => 'boolean',
            'tags' => 'array',
            'tags.*' => 'string',
        ];
    }
}
```

**Generated Bruno request body:**

```
{
  "name": "Name",
  "email": "user@example.com",
  "age": 18,
  "is_active": true,
  "tags": [""]
}
```

### Supported Rules

[](#supported-rules)

- **String types**: `string`, `email`, `url`, `uuid`
- **Numeric types**: `integer`, `numeric`, `decimal`
- **Boolean**: `boolean`, `bool`
- **Arrays**: `array`, nested arrays with `.*`
- **Dates**: `date`, `datetime`, `date_format`
- **Files**: `file`, `image`

### Nested Fields

[](#nested-fields)

```
'user.name' => 'required|string',
'user.email' => 'required|email',
```

Generates:

```
{
  "user": {
    "name": "Name",
    "email": "user@example.com"
  }
}
```

Working with Multiple Environments
----------------------------------

[](#working-with-multiple-environments)

The package generates separate environment files for Local, Staging, and Production by default. This allows you to seamlessly switch between different API endpoints while testing.

### Environment Configuration

[](#environment-configuration)

#### 1. Configure Environment URLs

[](#1-configure-environment-urls)

Set your environment URLs in `.env`:

```
APP_URL=http://localhost:8000
STAGING_URL=https://staging.myapp.com
PRODUCTION_URL=https://api.myapp.com
```

#### 2. Generate the Collection

[](#2-generate-the-collection)

```
php artisan bruno:generate
```

This creates environment files in `bruno/collections/Laravel-API/environments/`:

```
environments/
├── Local.bru
├── Staging.bru
└── Production.bru

```

#### 3. Switch Environments in Bruno

[](#3-switch-environments-in-bruno)

1. Open your collection in Bruno
2. Click the environment dropdown in the top-right
3. Select your desired environment (Local, Staging, or Production)
4. All requests will now use that environment's `baseUrl`

### Environment Variables

[](#environment-variables-1)

Each environment file contains variables that can be referenced in your requests using `{{variableName}}` syntax:

**Local.bru:**

```
vars {
  baseUrl: http://localhost:8000
  authToken:
}

```

**Staging.bru:**

```
vars {
  baseUrl: https://staging.myapp.com
  authToken: your-staging-token-here
}

```

**Production.bru:**

```
vars {
  baseUrl: https://api.myapp.com
  authToken: your-production-token-here
}

```

### Adding Custom Environment Variables

[](#adding-custom-environment-variables)

You can add custom variables to each environment in the config file:

```
'environments' => [
    'Local' => [
        'baseUrl' => env('APP_URL', 'http://localhost:8000'),
        'authToken' => '',
        'apiKey' => env('LOCAL_API_KEY', ''),
        'tenantId' => 'local-tenant',
    ],
    'Staging' => [
        'baseUrl' => env('STAGING_URL', 'https://staging.example.com'),
        'authToken' => '',
        'apiKey' => env('STAGING_API_KEY', ''),
        'tenantId' => 'staging-tenant',
    ],
    'Production' => [
        'baseUrl' => env('PRODUCTION_URL', 'https://api.example.com'),
        'authToken' => '',
        'apiKey' => env('PRODUCTION_API_KEY', ''),
        'tenantId' => 'prod-tenant',
    ],
],
```

Then use these variables in your requests:

```
headers {
  X-API-Key: {{apiKey}}
  X-Tenant-ID: {{tenantId}}
}

```

### Adding New Environments

[](#adding-new-environments)

You can add custom environments like Development, QA, or UAT:

```
'environments' => [
    'Local' => [
        'baseUrl' => env('APP_URL', 'http://localhost:8000'),
        'authToken' => '',
    ],
    'Development' => [
        'baseUrl' => env('DEV_URL', 'https://dev.example.com'),
        'authToken' => '',
    ],
    'QA' => [
        'baseUrl' => env('QA_URL', 'https://qa.example.com'),
        'authToken' => '',
    ],
    'UAT' => [
        'baseUrl' => env('UAT_URL', 'https://uat.example.com'),
        'authToken' => '',
    ],
    'Staging' => [
        'baseUrl' => env('STAGING_URL', 'https://staging.example.com'),
        'authToken' => '',
    ],
    'Production' => [
        'baseUrl' => env('PRODUCTION_URL', 'https://api.example.com'),
        'authToken' => '',
    ],
],
```

### Environment-Specific Authentication

[](#environment-specific-authentication)

Each environment can have its own authentication token. After generating the collection:

1. Open the environment file (e.g., `environments/Staging.bru`)
2. Add your authentication token:

```
vars {
  baseUrl: https://staging.myapp.com
  authToken: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
}

```

3. Requests using `{{authToken}}` will automatically use the environment-specific token

### Best Practices for Multi-Environment Setup

[](#best-practices-for-multi-environment-setup)

1. **Never commit tokens** - Add `*.bru` files with tokens to `.gitignore` or use environment variables
2. **Use descriptive names** - Name environments based on your deployment pipeline
3. **Keep URLs in .env** - Store all environment URLs in your `.env` file for easy management
4. **Document required variables** - Add comments in config to explain custom variables
5. **Test each environment** - Verify requests work correctly in each environment
6. **Use environment-specific data** - Configure test data IDs per environment if needed

### Example: Complete Multi-Environment Setup

[](#example-complete-multi-environment-setup)

**.env file:**

```
# Local Development
APP_URL=http://localhost:8000

# Remote Environments
DEV_URL=https://dev-api.myapp.com
STAGING_URL=https://staging-api.myapp.com
PRODUCTION_URL=https://api.myapp.com

# API Keys (optional)
DEV_API_KEY=dev_key_123
STAGING_API_KEY=staging_key_456
PRODUCTION_API_KEY=prod_key_789
```

**config/bruno-generator.php:**

```
'environments' => [
    'Local' => [
        'baseUrl' => env('APP_URL'),
        'authToken' => '',
        'apiKey' => '',
        'debug' => true,
    ],
    'Development' => [
        'baseUrl' => env('DEV_URL'),
        'authToken' => '',
        'apiKey' => env('DEV_API_KEY'),
        'debug' => true,
    ],
    'Staging' => [
        'baseUrl' => env('STAGING_URL'),
        'authToken' => '',
        'apiKey' => env('STAGING_API_KEY'),
        'debug' => false,
    ],
    'Production' => [
        'baseUrl' => env('PRODUCTION_URL'),
        'authToken' => '',
        'apiKey' => env('PRODUCTION_API_KEY'),
        'debug' => false,
    ],
],
```

After generation, manually add your auth tokens to each environment file in Bruno.

Output Structure
----------------

[](#output-structure)

```
bruno/collections/Laravel-API/
├── bruno.json
├── environments/
│   ├── Local.bru
│   ├── Staging.bru
│   └── Production.bru
├── api/
│   └── v1/
│       ├── users/
│       │   ├── get-users.bru
│       │   ├── post-users.bru
│       │   └── get-users-id.bru
│       └── posts/
│           ├── get-posts.bru
│           └── post-posts.bru
└── get-health.bru

```

Bruno File Format
-----------------

[](#bruno-file-format)

Each `.bru` file contains all the request details:

```
meta {
  name: Get Users
  type: http
  seq: 1
}

get {
  url: {{baseUrl}}/api/users
  body: none
  auth: none
}

headers {
  Accept: application/json
}

auth:bearer {
  token: {{authToken}}
}

```

Advanced Features
-----------------

[](#advanced-features)

### PHPDoc Documentation

[](#phpdoc-documentation)

Extract documentation from controller methods:

```
/**
 * Retrieve all users with pagination.
 *
 * Returns a paginated list of users with their profiles.
 */
public function index()
{
    //...
}
```

### Test Generation

[](#test-generation)

Generate basic test assertions:

```
tests {
  test("should return successful response", function() {
    expect(res.getStatus()).to.equal(200);
  });
}
```

### Custom Scripts

[](#custom-scripts)

Add pre-request or post-response scripts via configuration:

```
'script_templates' => [
    'pre_request' => [
        'bru.setVar("timestamp", Date.now());',
    ],
],
```

Best Practices
--------------

[](#best-practices)

1. **Use --dry-run first** - Preview the output before generating
2. **Filter routes carefully** - Only include routes you need to test
3. **Enable body inference** - Save time with automatic request bodies
4. **Use environments** - Configure multiple environments from the start
5. **Version control** - Commit the generated collection to track API changes
6. **Regenerate regularly** - Keep the collection in sync with route changes

Testing
-------

[](#testing)

Run the package tests:

```
composer test
```

Run tests with coverage:

```
composer test-coverage
```

Run static analysis:

```
composer analyse
```

Format code:

```
composer format
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on recent changes.

Contributing
------------

[](#contributing)

Contributions are welcome! Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security-related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Shahghasi Adil](https://github.com/shahghasiadil)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Support
-------

[](#support)

- **Issues**: [GitHub Issues](https://github.com/shahghasiadil/laravel-bruno-generator/issues)
- **Documentation**: [Full Documentation](https://github.com/shahghasiadil/laravel-bruno-generator)
- **Discussions**: [GitHub Discussions](https://github.com/shahghasiadil/laravel-bruno-generator/discussions)

---

**Built with ❤️ for the Laravel and Bruno communities**

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance85

Actively maintained with recent releases

Popularity26

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 91.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~43 days

Total

3

Last Release

56d ago

PHP version history (2 changes)v1.0.0PHP ^8.1|^8.2|^8.3

v1.0.2PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/0a0a3bb25b5438613463e20699f30cc02e24a0e57e7d171208e3d19bd6bf7b4a?d=identicon)[shahghasiadil](/maintainers/shahghasiadil)

---

Top Contributors

[![shahghasiadil](https://avatars.githubusercontent.com/u/64509320?v=4)](https://github.com/shahghasiadil "shahghasiadil (22 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")

---

Tags

apiapi-clientbrunocollectiondevelopement-toolslaravellaravel-brunotestingtesting-toolstestingapilaravelgeneratorcollectionapi clientdevelopment-toolsbruno

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/shahghasiadil-laravel-bruno-generator/health.svg)

```
[![Health](https://phpackages.com/badges/shahghasiadil-laravel-bruno-generator/health.svg)](https://phpackages.com/packages/shahghasiadil-laravel-bruno-generator)
```

###  Alternatives

[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k43.5M5.2k](/packages/larastan-larastan)[andreaselia/laravel-api-to-postman

Generate a Postman collection automatically from your Laravel API

1.0k586.2k3](/packages/andreaselia-laravel-api-to-postman)[tightenco/jigsaw

Simple static sites with Laravel's Blade.

2.2k438.5k29](/packages/tightenco-jigsaw)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[laravel/roster

Detect packages &amp; approaches in use within a Laravel project

15410.4M7](/packages/laravel-roster)[laravel/folio

Page based routing for Laravel.

608453.9k27](/packages/laravel-folio)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
