Download the PHP package zvonchuk/phalcon-openapi without Composer
On this page you can find all versions of the php package zvonchuk/phalcon-openapi. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download zvonchuk/phalcon-openapi
More information about zvonchuk/phalcon-openapi
Files in zvonchuk/phalcon-openapi
Package phalcon-openapi
Short Description Automatic OpenAPI 3.1 spec generation for Phalcon PHP — zero annotations, convention-based inference
License MIT
Homepage https://github.com/zvonchuk/phalcon-openapi
Informations about the package phalcon-openapi
phalcon-openapi
Automatic OpenAPI 3.1 spec generation for Phalcon PHP applications.
Generates a complete OpenAPI spec by reading your routes, controllers, models, and DTOs — no annotations, no YAML, no manual work. Just write your code and get Swagger UI for free.
Why This Package
| Annotation-based approach | phalcon-openapi | |
|---|---|---|
| Routes | Duplicated in annotations | Read from Phalcon Router automatically |
| Schemas | Separate schema definitions | Built from your existing DTOs and Models |
| Validation | Documentation only | Same attributes for docs AND runtime |
| Status codes | Manual per-endpoint | Convention-based (201, 204, 422, 404) |
| Setup | Custom controller + HTML | Two lines of code |
Requirements
- PHP 8.1+
- Phalcon 5.x
Installation
Quick Start
Two endpoints are registered automatically:
GET /api/openapi.json— OpenAPI 3.1 JSON specGET /api/docs— Swagger UI
How It Works
The package automatically reads:
- Router — all registered routes, HTTP methods, path patterns
- Model MetaData — column types, nullable, primary keys
- Reflection — controller action parameters, return types, docblocks
- PHP 8 Attributes — optional tags, hidden endpoints, extra responses, security
Convention-Based Inference
Zero annotations needed for standard CRUD:
The spec generator infers:
- Status codes:
create→ 201,delete→ 204, others → 200 - 422 Validation Error: auto-added when endpoint has a DTO body parameter
- 404 Not Found: auto-added when route has path parameters
- operationId: generated from controller + action name
- Tags: from controller name (
UserController→Users) - Schemas: from Phalcon Model metadata or DTO class properties
Attributes Reference
All attributes are optional — use only when conventions aren't enough.
Endpoint Attributes
Validation Attributes
Used for both runtime validation (via DtoValidator) and OpenAPI schema generation:
| Attribute | Validates | OpenAPI Schema |
|---|---|---|
#[Email] |
Valid email format | format: email |
#[StringLength(min: 1, max: 255)] |
String length bounds | minLength, maxLength |
#[Min(1)], #[Max(150)] |
Numeric range | minimum, maximum |
#[Enum(['a', 'b'])] |
Allowed values | enum: ["a", "b"] |
#[Url] |
Valid URL | format: uri |
#[NotBlank] |
Rejects whitespace-only | minLength: 1 |
#[Format('date')] |
Date/datetime/uuid/uri | format: date |
#[Pattern('/regex/')] |
PCRE regex match | pattern: regex |
Nested DTOs and Typed Arrays
Nested objects are validated recursively with dot-notation error paths:
Validation errors for nested objects use dot-notation:
Security Configuration
Then annotate controllers or methods with #[ApiSecurity('bearerAuth')].
Base Controller
Extend ApiController for automatic JSON body parsing, DTO validation,
and convenience helpers:
Configuration Options
Demo Application
See phalcon-openapi-demo for a complete working example with Docker and CRUD controllers.
Running Tests
License
MIT
All versions of phalcon-openapi with dependencies
ext-phalcon Version ^5.0