muammarsiddiqui / apideck-laravel
Lightweight, beautiful, zero-config API playground and explorer for Laravel APIs
Package info
github.com/MuammarSiddiqui/apideck-laravel
Language:JavaScript
pkg:composer/muammarsiddiqui/apideck-laravel
Requires
- php: >=8.0
- illuminate/http: ^9.0|^10.0|^11.0|^12.0
- illuminate/routing: ^9.0|^10.0|^11.0|^12.0
- illuminate/support: ^9.0|^10.0|^11.0|^12.0
README
Lightweight, beautiful, zero-config API playground and explorer for Laravel APIs.
ApiDeck automatically inspects your Laravel routes and controllers to generate a stunning UI allowing you to browse, test, and document your API without writing manual OpenAPI YAML files or docblocks.
Features
- Zero Config: Just require the package and visit
/apideck. - Dynamic Schema Reflection: ApiDeck uses PHP Reflection to automatically read your type-hinted Controller parameters (DTOs, FormRequests) and generate JSON examples in the UI!
- Modern UI: Sleek, fully responsive, dark-mode ready interface.
- Native Integration: Seamlessly integrates with Laravel's internal router.
Installation
Install the package via Composer:
composer require muammarsiddiqui/apideck-laravel
Because of Laravel's package auto-discovery, the service provider will be registered automatically!
Quick Start
You don't need to do anything. Simply define your routes in routes/api.php or routes/web.php:
Route::prefix('api/v1')->group(function () { Route::get('users', [UserController::class, 'index']); Route::post('users', [UserController::class, 'store']); });
Then open http://localhost:8000/apideck in your browser!
(Note: ApiDeck automatically filters out routes that don't belong to your API to keep the interface clean).
Advanced: Dynamic Schema Reflection (Auto-Example Generation)
ApiDeck features a powerful PHP Reflection engine. If you want ApiDeck to automatically generate Example JSON payloads and field schemas in the UI for your POST/PUT requests, all you have to do is strongly type-hint your controller methods or route closures!
Using a DTO / Class
If you type-hint a custom class, ApiDeck will read its public properties:
// Define your DTO class class CreateUserDTO { public string $name; public string $email; public int $age; public bool $isActive; } // In your routes or controller: Route::post('api/users', function (CreateUserDTO $payload) { return response()->json(['success' => true]); });
Using Form Requests
If you type-hint a standard Laravel FormRequest, ApiDeck will try to instantiate it and parse its rules() array to map out the fields:
namespace App\Http\Requests; use Illuminate\Foundation\Http\FormRequest; class StoreUserRequest extends FormRequest { public function rules() { return [ 'name' => 'required|string', 'email' => 'required|email' ]; } } // In your controller public function store(StoreUserRequest $request) { // ... }
ApiDeck will automatically reflect on these injected parameters and display fully populated JSON example payloads in the interface!
Configuration (Optional)
If you need to change the base URL or other behavior, publish the config file:
php artisan vendor:publish --provider="ApiDeck\Laravel\ApiDeckServiceProvider"