A PHP framework for building REST and GraphQL APIs with automatic docs, an admin UI, and generated Next.js, Nuxt, or React Native clients.
Luracast/Restler
A PHP 8+ REST API framework that generates routes, validation and OpenAPI docs from plain class methods using reflection.
- Stars
- 1,386
- Forks
- 313
- Open issues
- 33
- Last commit
- 3 days ago
What is it?
Restler lets you write API logic as ordinary PHP class methods. It uses reflection and PHPDoc or attributes to map methods to HTTP routes, validate typed parameters, and produce OpenAPI 3.0 documentation with a built-in Swagger UI explorer, so most of the routing and controller plumbing is not written by hand.
By default responses are JSON, and file extensions such as .xml, .csv or .xlsx can select other output formats once they are configured. The framework can run under PHP-FPM, on Swoole or OpenSwoole for persistent high-throughput serving, on ReactPHP, on Workerman, or on AWS Lambda through Bref. It also includes GraphQL support, OAuth 2.0 server examples, and rate limiting.
The project targets PHP 8.0 and later and is installed with Composer. Its README includes a migration guide from v5 and example projects covering CRUD, authentication, versioning and HTML templates.
Key features
- 01Maps class methods to REST routes automatically via reflection
- 02Validates typed parameters and returns proper HTTP status codes
- 03Generates OpenAPI 3.0 docs from PHPDoc comments with Swagger UI
- 04Supports JSON by default and XML, CSV, XLSX, YAML and HTML when configured
- 05Runs on PHP-FPM, Swoole/OpenSwoole, ReactPHP, Workerman or AWS Lambda
- 06Includes GraphQL support, rate limiting and OAuth 2.0 server examples
Use cases
- Building internal APIs or microservices in an existing PHP codebase
- Serving JSON to modern clients and XML or CSV to legacy systems from the same endpoints
- Exporting large datasets as CSV or Excel using generator streaming
- Modernizing an older PHP application by adding a REST API layer
Quick start
- 1
Install the package with Composer
composer require luracast/restler:^6.0 - 2
Create an API class and a public/index.php gateway that maps it (see README)
- 3
Start the built-in PHP server
php -S localhost:8080 -t public
Things to know
- Requires PHP 8.0 or newer.
- No license is specified in the project metadata.
- Version 6 has breaking changes from v5, so upgrading needs the migration guide.
In collections
Topics
FAQ
- What is Restler?
- A PHP 8+ REST API framework that generates routes, validation and OpenAPI docs from plain class methods using reflection. Restler lets you write API logic as ordinary PHP class methods. It uses reflection and PHPDoc or attributes to map methods to HTTP routes, validate typed parameters, and produce OpenAPI 3.0 documentation with a built-in Swagger UI explorer, so most of the routing and controller plumbing is not written by hand.
- Is Restler free to use? What license does it have?
- Restler has no declared license. Its code is public, but without a license you have no explicit permission to reuse it; ask the author before relying on it.
- Is Restler still maintained?
- Actively maintained. The last commit to Restler was on Nov 4, 2026.
- What can I use Restler for?
- Building internal APIs or microservices in an existing PHP codebase Serving JSON to modern clients and XML or CSV to legacy systems from the same endpoints Exporting large datasets as CSV or Excel using generator streaming Modernizing an older PHP application by adding a REST API layer
- How do I install Restler?
- Install the package with Composer: composer require luracast/restler:^6.0 Create an API class and a public/index.php gateway that maps it (see README) Start the built-in PHP server: php -S localhost:8080 -t public
- Where can I get Restler?
- The source code and installation instructions are on GitHub: https://github.com/Luracast/Restler
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A Python web framework for building type-hinted REST APIs on top of Django, with automatic OpenAPI docs and Pydantic validation.
A flexible ASGI Python web framework for building APIs, with data validation, dependency injection, OpenAPI generation and ORM integration.
An adapter that runs Laravel and Lumen applications on Swoole as a long-lived, memory-resident PHP server with WebSocket, TCP/UDP and async task support.
Symfony is a PHP framework for building web and console applications, plus a set of reusable PHP components.
A Python web framework for building APIs with standard type hints, offering automatic validation, OpenAPI docs and high performance.