Download the PHP package jkbennemann/laravel-api-documentation without Composer

On this page you can find all versions of the php package jkbennemann/laravel-api-documentation. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-api-documentation

Laravel API Documentation

Latest Version on Packagist Total Downloads

Overview

Laravel API Documentation is a powerful package that automatically generates OpenAPI 3.0 documentation from your Laravel application code. It eliminates the need to manually write and maintain API documentation by intelligently analyzing your routes, controllers, requests, and responses.

Key Features

Installation

1. Install via Composer

2. Publish Configuration (Optional)

3. Link Storage Directory

The package stores documentation in your storage directory. Make it accessible with:

Configuration

Default Settings

Out of the box, the package:

Documentation Storage

To include the generated documentation in version control, update your .gitignore:

Custom Storage Location

For a more accessible location, add a custom disk in config/filesystems.php:

Then update your config:

CI/CD Integration

Add documentation generation to your deployment workflow:

Or add to your composer.json scripts:

Usage

Generating Documentation

This command scans your application routes and generates an OpenAPI 3.0 specification file at your configured location.

Viewing Documentation

By default, the documentation is accessible at:

To enable the UIs, update your configuration:

Specifying Files to Generate

Generate documentation for specific files only:

This generates api-v1.json based on your configuration settings.

How It Works

The package analyzes your Laravel application using several intelligent components:

  1. Route Analysis: Scans all registered routes to identify controllers, HTTP methods, and path parameters
  2. Controller Analysis: Examines controller methods to determine response types and structures
  3. Request Analysis: Processes FormRequest classes to extract validation rules and convert them to OpenAPI parameters
  4. Response Analysis: Detects return types and analyzes method bodies to determine response structures

Key Features

Zero-Configuration Detection

The package automatically detects and documents your API with minimal configuration:

Response Type Detection

Controller Support

Request Parameter Extraction

Validation & Type Detection

Resource & Collection Support

Recent Enhancements

Route Parameter Handling

Spatie Data Integration

Dynamic Response Analysis


For more information on the OpenAPI specification, see OpenAPI Specification.

Enhancing Documentation with Attributes

While the package works automatically, you can enhance your documentation using PHP 8 attributes.

Controller Method Attributes

Available parameters:

This will add a new field to the route object in the OpenAPI file:

Request/Resource attributes

For request or resource classes the same attributes can be used as for the routes, except for the Tag attribute.
In addition to that the following attributes are available:

1. PathParameter

This attribute can be used to specify additional information about path parameters in your routes.
It can be applied to controller methods to enhance the documentation of route parameters like {id}, {user}, etc.

Available parameters:

2. Parameter

This attribute can be used to specify additional information about request or response parameters.
It can be applied at both class level and method level (e.g., on the rules() method of FormRequest classes).

Available parameters:

Method Level Usage (FormRequest):

Class Level Usage (Resource):

📋 Query Parameter Annotations

In addition to attributes, the package supports @queryParam annotations for documenting query parameters:

This automatically generates query parameter documentation in the OpenAPI specification.

💡 Usage Examples & Best Practices

Here are some comprehensive examples showing how to leverage the automatic detection features:

Example 1: Complete Controller with Automatic Detection

Example 2: Advanced FormRequest with Nested Parameters

Example 3: Invokable Controllers with Class-Level Attributes

Laravel's invokable controllers (single-action controllers) are fully supported with class-level attribute processing:

Key Features for Invokable Controllers:

Route Registration:

Example 4: Resource with Spatie Data Integration

Example 5: Union Types with Multiple Response Formats

🎯 Best Practices

  1. Leverage Automatic Detection: Let the package automatically detect response types and validation rules
  2. Use Attributes for Enhancement: Add #[Parameter] and #[PathParameter] attributes only when you need to provide additional context
  3. Document Complex Scenarios: Use @queryParam annotations for query parameters and union return types for multiple response formats
  4. Structured Validation: Use nested validation rules for complex request structures
  5. Consistent Naming: Use consistent parameter naming across your API for better documentation

Roadmap

Completed Features

🚀 Planned Enhancements

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-api-documentation with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/contracts Version ^10.0 || ^11.0 || ^12.0
nikic/php-parser Version ^5.3
php-openapi/openapi Version ^2.0
spatie/laravel-package-tools Version ^1.16
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package jkbennemann/laravel-api-documentation contains the following files

Loading the files please wait ....