mertcanureten/laravel-postman-collection 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mertcanureten/laravel-postman-collection

最新稳定版本:v1.0.5

Composer 安装命令:

composer require mertcanureten/laravel-postman-collection

包简介

A Laravel package to generate Postman collections from API routes.

README 文档

README

This is a Laravel package that allows you to generate a Postman collection from your Laravel API routes and export it for easy import into the Postman application.

Features

  • 🔄 Automatically generates Postman collection from Laravel API routes
  • 🔑 Built-in authentication support (Bearer Token, Basic Auth)
  • 📁 Groups API endpoints by their URL prefix for better organization
  • 📝 Includes route descriptions from PHPDoc comments
  • 🔍 Dynamic model parameter detection
  • 🎯 Default headers for JSON API requests
  • ⚡ Easy to install and use

Installation

You can install this package via Composer:

composer require mertcanureten/laravel-postman-collection

Usage

Once the package is installed, you can use the following Artisan command to export your API routes to a Postman collection:

php artisan postman:export

Command Options

  • --output: Specify the output file name (default: postman_collection.json)
  • --name: Set a custom name for the collection
  • --auth-type: Specify the authentication type (bearer|basic)

Examples

Basic usage:

php artisan postman:export

With custom options:

php artisan postman:export --output=api.json --name="My API" --auth-type=bearer

Generated Collection Features

The generated Postman collection includes:

  • Grouped endpoints by URL prefix
  • Authentication settings (Bearer Token by default)
  • Default headers for JSON API requests:
    • Accept: application/json
    • Content-Type: application/json
  • Route descriptions from PHPDoc comments
  • Parameter details with types and descriptions
  • Pre-configured JSON request bodies

Importing into Postman

After generating the collection, follow these steps to import it into Postman:

  1. Open Postman
  2. Click on "Import" in the top-left corner
  3. Select the generated JSON file
  4. Click "Import" to add the collection to your workspace

Authentication Setup

The collection comes with pre-configured Bearer Token authentication. To use it:

  1. Create an environment in Postman
  2. Add a variable named auth_token
  3. Set your API token as the variable value

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

统计信息

  • 总下载量: 8
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2024-09-26