Download the PHP package kayne/swagger without Composer
On this page you can find all versions of the php package kayne/swagger. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kayne/swagger
More information about kayne/swagger
Files in kayne/swagger
Package swagger
Short Description A minimal Swagger/OpenAPI documentation generator for Laravel using DTOs. 80% less code than l5-swagger with type-safe validation.
License MIT
Homepage https://github.com/YOUR_USERNAME/swagger
Informations about the package swagger
Kayne-Swagger
A minimal, clean Swagger/OpenAPI documentation generator for Laravel using strongly-typed DTOs.
Features
- Type-Safe DTOs: Use PHP 8.1+ type hints instead of doc comments
- FormRequestDto Support: Seamlessly integrate existing FormRequest with Swagger
- Minimal Code: 80% less boilerplate than l5-swagger
- Auto-Validation: Automatic validation from type definitions
- Auto Security Detection: Automatically detect JWT/Bearer token from route middleware
- Form Body Support: Support form-data and x-www-form-urlencoded like .NET
- Query Parameters: Auto-convert FormRequestDto to query params in GET requests
- Nested Arrays: Full support for nested arrays and array items
- Clean Syntax: Modern PHP attributes instead of verbose annotations
- DRY Principle: Define once, use everywhere
- Like .NET Swagger: Fast and efficient like .NET Core
Installation
The package will auto-register via Laravel's package discovery.
See INSTALLATION.md for detailed installation guide.
Quick Start
1. Create a DTO (Optional annotations!)
2. Use in Controller (Only 3 required fields!)
3. Register Routes with Middleware
4. View Documentation
Visit: http://your-app.test/api/documentation
Advanced Features
FormRequestDto - Use Existing FormRequest
Auto Security Detection from Route Group
→ Automatically adds bearerAuth security from middleware token!
Form Body Support
Array Items Support
Documentation
See USAGE.md for detailed documentation (Vietnamese).
Comparison with l5-swagger
l5-swagger (Old way)
Kayne-Swagger (New way)
93% less code!
Why Kayne-Swagger?
- Minimal: Only 3 required fields (method, path, tags)
- Smart Detection: Auto-detect request body, path params, query params, security
- FormRequest Support: Use existing FormRequest without rewriting
- Auto Security: Automatically detect JWT/Bearer token from route middleware
- Form Body: Support form-data and x-www-form-urlencoded like .NET
- Less Clutter: Annotations are optional!
- Type Safety: Leverages PHP's type system
- Auto-Validation: Validation rules from types
- Modern PHP: Uses PHP 8.1+ attributes
- DRY: Single source of truth for data structure
- Fast: Like .NET's Swagger generation
Available Property Attributes
php // Path parameter - auto-detected from {id}
[Api(method: 'GET', path: '/api/users/{id}', tags: ['Users'])]
public function show(int $id) { }
// Query parameters - auto-detected
[Api(method: 'GET', path: '/api/users', tags: ['Users'])]
public function index(?int $page = 1, ?int $limit = 10) { }
Api Attributes (Only 3 Required!)
Property Attributes (All Optional!)
You can even skip all Property attributes and just use type hints!
Configuration
Publish config (optional):
Configure in .env:
Security Configuration
Auto-detect middleware names and map to security schemes:
Auto-Generate Annotations
Use the command to automatically generate #[Api(...)] annotations from your routes:
Or use full class name:
Or use file path:
Features:
- Automatically detects HTTP method, path, and middleware from routes
- Generates tags from controller name (e.g.,
UserController→User) - Auto-detects security from middleware (e.g.,
auth:sanctum→bearerAuth) - Generates summary from method name
- Won't overwrite existing annotations (use
--forceto regenerate)
Example:
Before:
After running command:
Options:
--force: Force regenerate even if annotation exists
Controller Name Resolution:
- Command tự động tìm controller trong các namespace phổ biến:
App\Http\Controllers\Api\App\Http\Controllers\App\Controllers\Api\App\Controllers\
- Có thể dùng tên ngắn:
LoginControllerhoặcLogin(tự động thêmControllersuffix) - Hoặc dùng full class name:
App\Http\Controllers\Api\LoginController
\
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
MIT License
Credits
Inspired by .NET's minimal API approach and frustrated with l5-swagger's verbosity.
Made with ❤️ for Laravel developers who love clean code
All versions of swagger with dependencies
illuminate/support Version ^10.0|^11.0|^12.0
illuminate/routing Version ^10.0|^11.0|^12.0
illuminate/http Version ^10.0|^11.0|^12.0
illuminate/validation Version ^10.0|^11.0|^12.0