A powerful and elegant API documentation generator for Laravel applications with an interactive request testing interface.
Sculpt is a modern Laravel package that generates comprehensive, interactive API documentation from your application's routes. It provides developers with a clean, user-friendly interface to explore, understand, and test all available API endpoints without leaving the browser.
Key features:
- Automatic Route Scanning - Discovers and documents all API routes
- Interactive Testing - Send GET, POST, PUT, PATCH, DELETE requests directly from the documentation
- Smart Parameter Handling - Support for query parameters, request body, and custom headers
- Real-time Response Display - View API responses with syntax highlighting and response timing metrics
- Beautiful UI - Modern dark theme interface built with Tailwind CSS
- Zero Configuration - Works out of the box with sensible defaults
Sculpt is built following clean architecture principles with clear separation of concerns:
- Main service orchestrating documentation generation
- Collects route information from the Laravel router
- Generates OpenAPI 3.1.0 specification
- Scans Laravel routes and extracts metadata
- Filters API routes from the application
- Implements
CollectorInterfacefor extensibility
- Extracts request/response schema from DTO classes
- Analyzes controller methods for documentation metadata
- Generates JSON Schema representations
- Converts collected data into OpenAPI specification
- Supports OpenAPI 3.1.0 format
- Includes server configuration and metadata
- Laravel service provider for package registration
- Registers routes and publishes configuration
- Handles package bootstrap
- Handles documentation page requests
- Renders the interactive documentation blade view
- Passes OpenAPI spec to frontend
- Laravel - ^10.0 | ^11.0 | ^12.0
- PHP - ^8.2
- Tailwind CSS - Modern styling framework
- Highlight.js - Code syntax highlighting
- OpenAPI - 3.1.0 specification standard
- Spatie Laravel Data - DTO validation and transformation
- PHPUnit - ^10.0 | ^11.0 (for testing)
composer require sculpt/apidocThe package will be automatically registered via Laravel's package auto-discovery.
php artisan vendor:publish --provider="Sculpt\ApiDoc\ApiDocServiceProvider"This publishes the configuration file to config/sculpt.php where you can customize:
- Documentation title
- Description
- Version number
- Route prefix
- Server URL
Navigate to http://your-app.local/docs (or custom route prefix) to view your API documentation.
The package automatically scans your api/ routes. Just make sure your API routes are properly defined:
// routes/api.php
Route::get('/users', [UserController::class, 'index']);
Route::post('/users', [UserController::class, 'store']);
Route::get('/users/{id}', [UserController::class, 'show']);
Route::put('/users/{id}', [UserController::class, 'update']);
Route::delete('/users/{id}', [UserController::class, 'destroy']);Use Spatie Laravel Data for request/response DTO's:
use Spatie\LaravelData\Data;
class UserData extends Data
{
public function __construct(
public int $id,
public string $name,
public string $email,
public string $created_at,
) {}
}
// In your controller
class UserController extends Controller
{
public function index(): JsonResponse
{
return response()->json(UserData::collect(User::all()));
}
public function store(UserStoreRequest $request): JsonResponse
{
$user = User::create($request->validated());
return response()->json(UserData::from($user));
}
}// config/sculpt.php
return [
'title' => 'My API',
'description' => 'My awesome API documentation',
'version' => '1.0.0',
'route_prefix' => 'docs',
'enabled' => env('SCULPT_ENABLED', true),
];Each endpoint displays a "Try it out" button that opens a modal with:
- Request Builder - Construct requests with custom parameters
- Headers Section - Add/remove custom HTTP headers
- Query Parameters - For GET, DELETE, and other query-based requests
- Request Body - JSON editor for POST, PUT, PATCH methods
- Response Display - View status codes, response time, and formatted response body
The documentation intelligently displays form fields based on HTTP method:
- GET/DELETE - Query parameters and headers
- POST/PUT/PATCH - Request body, query parameters, and headers
All JSON examples and responses are automatically syntax-highlighted using Highlight.js for better readability.
The documentation interface is fully responsive:
- Desktop: Side navigation + main content
- Mobile: Collapsible sidebar for better space utilization
Beautiful dark theme optimized for reduced eye strain during development.
Run the test suite:
composer testRun tests with code coverage:
composer test -- --coverage// GET /api/products - List all products
// POST /api/products - Create new product
// GET /api/products/{id} - Get product details
// PUT /api/products/{id} - Update product
// DELETE /api/products/{id} - Delete product
// GET /api/orders - List orders
// POST /api/orders - Place new order
// GET /api/orders/{id} - Get order details// GET /api/users - List users
// POST /api/users - Create user
// GET /api/users/{id} - Get user profile
// PUT /api/users/{id} - Update profile
// DELETE /api/users/{id} - Delete user
// POST /api/users/{id}/avatar - Upload avatar- Route Discovery - Sculpt scans your
api/routes at documentation request time - Metadata Extraction - Analyzes controller methods for documentation hints
- DTO Analysis - Examines DTO classes to generate request/response schemas
- OpenAPI Generation - Compiles everything into OpenAPI 3.1.0 format
- Frontend Rendering - Blade template renders interactive documentation UI
- Request Handling - JavaScript intercepts requests and displays responses in real-time
Modify the route prefix in config:
'route_prefix' => 'api-docs', // Now accessible at /api-docsPublish assets and customize the Blade template:
php artisan vendor:publish --provider="Sculpt\ApiDoc\ApiDocServiceProvider" --tag=viewsConfigure the API server URL for testing:
// config/sculpt.php
'servers' => [
['url' => env('API_URL', 'http://localhost:8000')],
],- Use DTOs - Leverage Spatie Laravel Data for type-safe request/response handling
- Add Descriptions - Use docblock comments on controller methods
- Type Hints - Always type-hint parameters and return types
- Consistent Naming - Use RESTful naming conventions for routes
- Version Your API - Use API versioning (e.g.,
/api/v1/users) - Validation Rules - Define comprehensive validation rules in Form Requests
- Ensure routes are in
api/prefix - Check that
SCULPT_ENABLEDenvironment variable is true - Verify routes are defined in
routes/api.php
- Clear browser cache
- Verify CDN is accessible
- Check browser console for JavaScript errors
- Verify CORS configuration allows the headers
- Check if headers require special Laravel middleware
- Ensure Authorization header if needed
Sculpt API Documentation is open-sourced software licensed under the MIT license.
Imran Imranov - Full-stack developer passionate about clean architecture and developer experience.
Contributions are welcome! Please feel free to submit a Pull Request or open an issue for bugs and feature requests.
# Clone repository
git clone https://github.com/yourusername/sculpt-apidoc.git
cd sculpt-apidoc
# Install dependencies
composer install
# Run tests
composer test
# Run code analysis
composer analyse- PHP Version Required: 8.2+
- Laravel Version: 10.0+
- Package Size: Minimal footprint
- Dependencies: Spatie Laravel Data only
- Code Coverage: 85%+
- Laravel - The PHP web framework
- Spatie Laravel Data - DTO management
- OpenAPI Specification - API documentation standard
- Tailwind CSS - Utility-first CSS framework
For support, issues, or questions:
- Open an issue on GitHub
- Check existing documentation
- Review test files for usage examples
Happy Documenting! π