Download the PHP package luracast/restler without Composer
On this page you can find all versions of the php package luracast/restler. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download luracast/restler
More information about luracast/restler
Files in luracast/restler
Package restler
Short Description Restler is a simple and effective multi-format Web API Server framework written in PHP. Just deal with your business logic in php, Restler will take care of the REST!
License MIT
Homepage https://luracast.com/products/restler/
Informations about the package restler
Restler v6
Write your API logic in PHP. Get routing, validation, and OpenAPI docs—automatically.
Production-ready since 2010. Battle-tested. Now rebuilt for modern PHP 8+ with async superpowers.
That's it. You just created a REST API that:
- ✅ Automatically validates
$idas an integer - ✅ Returns JSON by default
- ✅ Handles routing (
GET /products/123) - ✅ Generates OpenAPI/Swagger docs
- ✅ Provides proper HTTP status codes
- ✅ Supports content negotiation (configure other formats as needed)
No controllers. No routing files. No configuration. Just PHP.
Why Restler in 2025?
🎯 Zero Boilerplate
While other frameworks make you write controllers, routes, DTOs, validation rules, and transformers—Restler uses PHP reflection to do it all automatically. Write business logic, not plumbing.
⚡ Async Performance
Run on Swoole/OpenSwoole for 10-20x throughput vs traditional PHP-FPM. Or use ReactPHP for true async I/O. Deploy to AWS Lambda for serverless scale.
🌐 Multi-Format Output
JSON is the default format. Configure additional formats (XML, CSV, Excel, HTML) via Routes::setOverridingResponseMediaTypes(). Perfect for:
- Mobile apps → JSON (default)
- Legacy systems → XML
- Data exports → CSV/Excel
- Admin panels → HTML with Blade/Twig
🚀 Modern PHP 8+
Built for PHP 8 with attributes, union types, named arguments, and strict typing. PSR-7 and PSR-11 compliant.
📚 Auto-Generated Docs
OpenAPI 3.0 (Swagger) docs generated from your PHPDoc comments. Interactive API explorer included.
Real-World Use Cases
🏢 Internal APIs & Microservices
Perfect for building internal APIs that need to integrate with various systems. Multi-format support means you can serve JSON to your React app and XML to that ancient CRM system—from the same endpoint.
📱 Mobile Backend
Low latency on Swoole, automatic validation, built-in rate limiting, and OAuth2 support. Everything you need for a production mobile backend.
📊 Data Export APIs
Built-in CSV and Excel streaming support. Export millions of rows without running out of memory using generators.
🔗 Legacy System Integration
Need to modernize an old PHP app? Add Restler to get a REST API instantly. Works alongside existing code—no rewrite needed.
Quick Start
Install
Create Your First API (3 files)
1. API Class (api/Hello.php)
2. Gateway (public/index.php)
3. URL Rewriting (.htaccess or nginx.conf)
Test It
That's it! You have a working REST API with automatic routing, validation, and multi-format support.
Production Deployment
Traditional (Apache/Nginx + PHP-FPM)
Standard deployment. Works everywhere. ~1,000-2,000 req/sec depending on hardware.
High Performance (Swoole/OpenSwoole)
10-20x faster than PHP-FPM. Persistent connections, coroutines, built-in HTTP server.
Benchmarks: 15,000+ req/sec on modest hardware (vs ~1,000 for PHP-FPM)
Async I/O (ReactPHP)
True non-blocking async operations. Perfect for I/O-heavy workloads (database, HTTP calls, etc.).
Serverless (AWS Lambda)
Zero-downtime deploys, automatic scaling, pay-per-request pricing.
See public/index_lambda.php for complete example.
Event-Driven (Workerman)
Alternative to Swoole with pure PHP implementation (no extension required).
What's New in v6
🔥 Breaking Changes from v5
- PHP 8.0+ required (was PHP 7.4)
- PSR-7 HTTP messages (modern request/response objects)
- PSR-11 Container (standard dependency injection)
- Stricter typing (full PHP 8 type hints)
Migration Guide →
✨ New Features
Modern PHP 8 Support
- ✅ Attributes (
#[Get],#[Post], etc.) - ✅ Union types (
string|int,User|null) - ✅ Named arguments
- ✅ Constructor property promotion
- ✅ Match expressions
- ✅ Enums
Async & Performance
- ✅ Swoole/OpenSwoole integration (10-20x faster)
- ✅ ReactPHP async server
- ✅ Workerman event-driven server
- ✅ AWS Lambda serverless support
- ✅ Generator streaming for large datasets (CSV, Excel)
- ✅ Route caching & opcode optimization
Enhanced Security
- ✅ Secure session serialization (JSON, not
unserialize()) - ✅ JSONP callback validation (XSS prevention)
- ✅ Template injection protection
- ✅ Configurable CORS with proper defaults
- ✅ Built-in rate limiting
- ✅ OAuth 2.0 server support
Developer Experience
- ✅ GraphQL support
- ✅ Excel export (XLSX streaming)
- ✅ OpenAPI 3.0 spec generation
- ✅ Interactive API Explorer (Swagger UI)
- ✅ Better error messages
- ✅ Blade, Twig, Mustache template engines
- ✅ Modern DI container with auto-wiring
Multi-Format Support
All formats work automatically—just add file extension to URL:
- JSON (default)
- XML
- YAML
- CSV (with streaming)
- Excel (XLSX)
- HTML (with templates)
- AMF (Flash/Flex)
- Plist (iOS/macOS)
Advanced Examples
API Versioning
Usage:
Authentication & Rate Limiting
Database Integration
Automatic REST endpoints:
GET /products→ index()POST /products→ post()GET /products/123→ (auto-routes to index with $id)PUT /products/123→ put()DELETE /products/123→ delete()
File Uploads
Streaming Large Datasets
Custom Routing
GraphQL Support
CORS Configuration
Interactive API Explorer
Restler includes a built-in Swagger UI explorer:
Visit http://localhost:8080/explorer to:
- Browse all endpoints
- See request/response schemas
- Test APIs interactively
- Download OpenAPI spec
The explorer is auto-generated from your PHPDoc comments—no manual work needed.
Testing
Restler includes 18+ working examples and a full Behat test suite.
Run Built-in Tests
Results: 310/310 scenarios passing ✅
Write Your Own Tests
Example Projects
Try the included examples:
_001_helloworld- Minimal API_003_multiformat- JSON, XML, YAML, CSV_005_protected_api- Authentication_007_crud- Full CRUD with database_009_rate_limiting- Rate limiting_011_versioning- API versioning_013_html- HTML responses with templates_015_oauth2_server- OAuth 2.0 server_018_graphql- GraphQL integration
Performance Tips
1. Enable Production Mode
2. Use Swoole/OpenSwoole
10-20x performance improvement over PHP-FPM. Same code, no changes needed.
3. Use Generators for Large Datasets
4. Cache Expensive Operations
5. Optimize Database Queries
Framework Comparison
| Feature | Restler v6 | Laravel | Symfony | Slim |
|---|---|---|---|---|
| Auto-routing from methods | ✅ | ❌ | ❌ | ❌ |
| Multi-format (JSON/XML/CSV/Excel) | ✅ | Partial | Partial | ❌ |
| Auto OpenAPI docs | ✅ | Via package | Via package | Via package |
| Swoole support | ✅ | Via package | Via package | ❌ |
| Zero config | ✅ | ❌ | ❌ | Partial |
| Lines of code for CRUD API | ~20 | ~100 | ~150 | ~50 |
| Learning curve | Very Low | Medium | High | Low |
| Best for | APIs | Full-stack | Enterprise | Microservices |
Restler Philosophy: Write business logic. Get the REST for free.
Migration from v5
Upgrading from Restler v5? Most code works unchanged. Key changes:
Requirements
- PHP 8.0+ (was 7.4+)
- Add PSR-7 and PSR-11 to composer.json (auto-installed)
Type Hints (Recommended)
Breaking Changes
- Removed deprecated reflection methods (internal only)
- Session serialization now uses JSON (more secure)
- Some internal class reorganization
Full migration guide: MIGRATION.md
Documentation
- Annotations Reference - All PHPDoc annotations (
@url,@param, etc.) - Parameter Handling - Request parameter mapping
- Request Lifecycle - How Restler processes requests
- Forms - HTML form handling
- Composer Integration - Advanced setup
- Security Guide - Best practices
- Migration Guide - Upgrading from v5
- Changelog - Version history
FAQ
When should I use Restler?
✅ Great for:
- Internal APIs and microservices
- Mobile app backends
- Data export APIs (CSV, Excel)
- Rapid prototyping
- Modernizing legacy PHP apps
- APIs that need multiple formats (JSON + XML + CSV)
- High-performance requirements (with Swoole)
❌ Not ideal for:
- Full-stack web apps with server-side rendering (use Laravel/Symfony)
- GraphQL-first APIs (though GraphQL support is included)
- Non-PHP environments
How is this different from Laravel/Symfony?
Restler is laser-focused on APIs. Laravel and Symfony are full-stack frameworks that can build APIs, but require significantly more boilerplate. Restler uses reflection to eliminate boilerplate entirely.
Example: A CRUD API in Laravel requires routes, controllers, form requests, and resources (~100 lines). In Restler it's ~20 lines.
Is Swoole support production-ready?
Yes! Swoole has been production-ready since 2018. Used by companies like Alibaba, Tencent, and Baidu. OpenSwoole is a fork with the same stability. Both work identically with Restler.
Does it work with [my favorite ORM/database]?
Yes! Restler is database-agnostic. Use Eloquent, Doctrine, RedBeanPHP, PDO, or anything else. Examples included for all major ORMs.
Can I use it with Docker/Kubernetes?
Absolutely. Dockerfile examples included. Works great in containers, especially with Swoole for high performance.
Is it really production-ready?
Yes! Restler has been used in production since 2010. v6 is a complete rewrite for modern PHP 8+ with security improvements and async support. Currently powers APIs handling millions of requests daily.
What's the performance like?
- PHP-FPM: ~1,000-2,000 req/sec (typical)
- Swoole/OpenSwoole: ~15,000-20,000 req/sec (same hardware)
- AWS Lambda: Automatic scaling, cold start ~100ms
Actual numbers depend on your application logic and hardware.
Support & Community
- 📖 Documentation: Full docs
- 🐛 Bug Reports: GitHub Issues
- 🔒 Security: SECURITY.md
- 🌟 Star us on GitHub if you find Restler useful!
Contributing
We welcome contributions! Whether it's:
- 🐛 Bug fixes
- ✨ New features
- 📖 Documentation improvements
- 🧪 Test coverage
- 💡 Ideas and suggestions
See CONTRIBUTING.md for guidelines.
Development Setup
License
Restler is open-source software licensed under the MIT License.
Free for commercial and personal use.
Credits
Created and maintained by Luracast
Special thanks to all contributors who have helped make Restler better over the years!
All versions of restler with dependencies
ext-json Version *
psr/container Version ^2.0
guzzlehttp/guzzle Version ^7.5
ralouphie/getallheaders Version ^3
logicalsteps/async Version ^2.0
hansott/psr7-cookies Version ^3.0
ringcentral/psr7 Version ^1.3


