Download the PHP package abrha/laravel-data-docs without Composer

On this page you can find all versions of the php package abrha/laravel-data-docs. 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-data-docs

Laravel Data Docs

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Generate beautiful API documentation automatically from Spatie's Laravel Data classes. This package integrates seamlessly with Knuckles Scribe to extract request and response schemas directly from your Data DTOs, eliminating manual documentation of API parameters.

Features

Installation

You can install the package via composer:

Scribe Configuration

Register the package strategies in your config/scribe.php:

Optionally, publish the config file:

Basic Usage

1. Create Your Data Classes

2. Use in Your Controllers

3. Generate Documentation

That's it! Scribe will automatically extract request parameters from CreateUserRequest and response structure from UserResponse.

Available Attributes

The package automatically processes Laravel Data validation attributes to generate comprehensive OpenAPI documentation with validation rules, formats, and descriptions.

#[Hidden]

Excludes a property from generated documentation. Useful for internal flags, metadata, or sensitive fields.

#[Example]

Provides custom example values for API documentation instead of auto-generated examples.

#[QueryParameter]

Marks a property as a URL query parameter (for non-GET requests). GET requests treat all parameters as query parameters by default.

#[ResponseData]

Specifies the response DTO class for a controller method. Applied to controller methods, not Data classes.

Laravel Data Validation Attributes

The package has built-in support for Laravel Data validation attributes. These automatically add OpenAPI validation rules, formats, and descriptions:

Format Attributes:

String Pattern Attributes:

Numeric Validation:

Example:

This automatically generates OpenAPI documentation with:

Advanced Features

Nested Data Objects

The package automatically handles nested Data objects with dot notation:

Generated parameters:

Arrays of Data Objects

Arrays of Data objects are automatically handled with array notation:

Generated parameters:

Extending Functionality

The package provides four extension methods, ordered from simplest to most advanced:

1. Config File (Simplest)

The easiest way to customize documentation is through the config file. Define custom type mappings without writing any code:

Available configuration fields:

When to use: Simple type mappings where you just need to specify OpenAPI properties declaratively.

2. Custom Type Processors

For more dynamic control over type processing, implement a CustomTypeProcessor:

Register in your AppServiceProvider:

When to use: When you need programmatic control over type documentation or need to generate dynamic examples/descriptions based on the class itself.

3. Custom Attribute Processors

Process custom or existing validation attributes by implementing an AttributeProcessor. This allows you to create reusable attributes that modify documentation behavior.

Step 1: Create your custom attribute:

Step 2: Create the processor:

Step 3: Register in your AppServiceProvider:

Step 4: Use in your Data classes:

When to use: When you need reusable, attribute-based validation logic that can be applied to multiple properties across different Data classes. Great for domain-specific validations.

4. Custom Pipeline Stages (Most Advanced)

For complete control over the processing pipeline, implement custom stages. This gives you access to the full context and allows modification at any point in the pipeline.

Register your stage in the pipeline:

When to use: When you need to:

Note: This requires deeper understanding of the package internals and how the pipeline processes contexts.

Extension Method Summary

Method Complexity Use Case
Config File ⭐ Simple Static type mappings
Type Processor ⭐⭐ Moderate Dynamic type-specific logic
Attribute Processor ⭐⭐⭐ Moderate-Advanced Reusable attribute-based validation
Pipeline Stage ⭐⭐⭐⭐ Advanced Complex cross-cutting concerns

How It Works

Pipeline Architecture

The package uses a pipeline pattern to process each property in your Data classes:

  1. Context Creation: A ParameterContext object is created for each property
  2. Pipeline Processing: The context flows through multiple stages:
    • HiddenStage: Checks for #[Hidden] attribute
    • TypeStage: Determines base type from PHP type hints
    • CustomTypeStage: Applies custom type configurations
    • AttributeProcessingStage: Processes all attributes using registered AttributeProcessors (includes 30+ built-in Laravel Data validation attributes)
    • TypeDescriptionStage: Generates type descriptions
    • DefaultValueStage: Extracts default values
    • DefaultValueDescriptionStage: Generates default value descriptions
    • RequiredStage: Determines if field is required
    • ExampleGenerationStage: Generates example values using Faker
  3. Parameter Generation: Context is converted to API parameter format
  4. OpenAPI Enhancement: The ExtendedOpenApiGenerator merges additional OpenAPI schema information into the final specification

Scribe Integration

The package provides three Scribe strategies and an OpenAPI generator:

These strategies automatically detect Data classes in your controller methods and generate comprehensive documentation with validation rules.

Development

This project uses a Docker-based development environment with a long-running container for fast command execution.

Getting Started

Start the development container (do this once):

The container stays running in the background. All subsequent commands execute instantly without container startup overhead.

Available Commands

Run ./dev help to see all available commands.

Testing

Run all tests:

Run tests with coverage:

Or using composer:

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

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-data-docs with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
fakerphp/faker Version ^1.21
illuminate/support Version ^11.0|^12.0|^13.0
knuckleswtf/scribe Version ^4.0|^5.0
spatie/laravel-data Version ^4.14
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 abrha/laravel-data-docs contains the following files

Loading the files please wait ...