Generate Postman Collections from Laravel Routes

3 months ago 2

The yasintqvi/laravel-postman package generates Postman collections from your Laravel routes with intelligent organization and rich documentation capabilities.

This package offers comprehensive configuration options for generating the Postman collection, with conventions that get you started quickly. To use this package, you create the Postman collection with the following Artisan command:

php artisan postman:generate

This package includes configuration options for features such as route filtering, API authentication settings, file generation paths and filenames, and more. Here's an example of the generated api_collection file:

Generated Postman config from a default Laravel API app Generated Postman config from a default Laravel API app

After I generated an example Laravel project with artisan install:api and configured a few things—such as an API token—I was able to get things working Postman within minutes by importing via File -> Import:

My demo Postman collection after import My demo Postman collection after import

Main Features

  • Generate Postman collections with one command
  • Automatic request body generation from FormRequest validation rules
  • Multiple organization strategies (route prefix, controller, nested paths)
  • Built-in authentication support (Bearer, Basic Auth, API Keys)
  • Customizable route filtering
  • Environment variable support for sensitive data

💻 You can get started with this package on GitHub: yasintqvi/laravel-postman.

Read Entire Article