Skip to content

Introduction

In modern event-driven architectures, documenting broadcast events is as crucial as documenting REST APIs. laravel-async-api bridges this gap for Laravel applications by automating the generation of AsyncAPI specifications.

Stop maintaining manual AsyncAPI files. Document your events directly in your PHP code with a simple attribute, and let the package generate a fully compliant AsyncAPI 3.0 specification.

Features

  • Zero-Effort Documentation: Stop maintaining manual AsyncAPI files. Document your events directly in your PHP code.
  • Attribute-Based: Uses modern PHP 8 attributes for a clean and declarative developer experience.
  • Schema Integration: Automatically extracts payload schemas from DTOs or models, ensuring your documentation always matches your code.
  • Seamless Integration: Works perfectly with Laravel's broadcasting system (Reverb, Pusher, Soketi).
  • AsyncAPI 3.0 Compliant: Generates specifications that follow the latest AsyncAPI standard.
  • AI Agent Ready: Includes an official Laravel Boost skill to automatically teach AI agents (like Claude Code and Cursor) how to use this package in your project.

How It Works

Add the #[AsyncApi] attribute to your broadcast event classes:

php
use Victormgomes\AsyncApi\Attributes\AsyncApi;

#[AsyncApi]
class ChatMessage implements ShouldBroadcast
{
    // ...
}

The package discovers all #[AsyncApi]-attributed events that implement ShouldBroadcast, extracts their schemas, and registers a route that serves the AsyncAPI 3.0 JSON specification. Visit /docs/ws in your application to view the interactive documentation.