Download the PHP package progrmanial/fast-api without Composer
On this page you can find all versions of the php package progrmanial/fast-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download progrmanial/fast-api
More information about progrmanial/fast-api
Files in progrmanial/fast-api
Package fast-api
Short Description Standardised API Management Package
License MIT
Informations about the package fast-api
FastAPI Framework
FastAPI is a lightweight, powerful PHP framework designed to make building APIs fast, simple, and efficient. It provides a comprehensive set of features and tools to streamline the development process, allowing developers to focus on writing clean and maintainable code.
🚀 Features
- Advanced Routing: Intuitive routing system with route groups, prefixes, and nested structures
- Laravel-Style Syntax: String middleware and Controller@method syntax support
- Middleware System: Powerful middleware pipeline with auto-resolution
- JWT Token Handling: Complete JWT token generation, verification, and refresh capabilities
- Request/Response Handling: Rich HTTP request and response objects with multiple content types
- Custom Time Utilities: Advanced date/time manipulation and formatting
- String & Array Utilities: Comprehensive utility methods for common operations
- Rate Limiting: Revolutionary auto-fallback rate limiting with Redis → File fallback chain
- WebSocket Support: Real-time WebSocket server with broadcasting capabilities
- 100% Backward Compatible: All new features preserve existing functionality
- Type Safety: Proper error handling and validation throughout
- Singleton App Pattern: Efficient application lifecycle management
- Clean Architecture: Refactored App class with no duplicate methods and clear separation of concerns
📦 Installation
Install FastAPI using Composer:
🏁 Quick Start
Basic Application Setup
🛠 Core Components
1. WebSocket Support - Real-time Communication
FastAPI includes a pure PHP WebSocket implementation for real-time communication. The WebSocket functionality is 100% backward compatible and integrates seamlessly with existing HTTP routes.
Basic WebSocket Server
Fluent API Configuration
Broadcasting Messages
WebSocket Connection Management
Multiple WebSocket Servers
WebSocket with HTTP Routes
WebSocket Server Methods
WebSocket Connection Methods
WebSocket Protocol Support
The WebSocket implementation supports the full WebSocket protocol:
- Handshake: Automatic WebSocket upgrade handshake
- Framing: Text, binary, ping, pong, and close frames
- Masking: Client-to-server message masking
- Extensions: Support for WebSocket extensions
- Status Codes: Proper close codes and status handling
Error Handling
Performance Considerations
- Pure PHP: No external dependencies for WebSocket functionality
- Lightweight: Minimal memory footprint
- Scalable: Supports multiple concurrent connections
- Efficient: Non-blocking I/O with proper resource management
2. Router Class - Advanced Routing
The Router class provides powerful routing capabilities with support for groups, middleware, and Laravel-style syntax.
Basic Routing
Route Groups
Organize routes with common attributes:
Laravel-Style Syntax
Fluent API
2. App Class - Application Management
The App class manages the application lifecycle with singleton pattern and built-in features.
App-Level Route Groups
The App class supports the same powerful route grouping features as the Router class:
Important: App-level groups use Router's middleware aliasing system. You must register middleware aliases with $app->registerMiddleware()
before using them in groups.
WebSocket Support
FastAPI includes built-in WebSocket server capabilities for real-time applications:
WebSocket Features:
- Real-time Communication: Full WebSocket protocol support
- Broadcasting: Send messages to all connected clients
- Authentication: Secure WebSocket connections with tokens
- Multiple Servers: Run multiple WebSocket servers on different ports
- Event-based: JSON-based event system for structured communication
- Fluent API: Chainable methods for easy configuration
3. Request Class - HTTP Request Handling
Rich request object with dynamic properties and validation.
4. Response Class - HTTP Response Handling
Comprehensive response handling with multiple content types.
5. Token Class - JWT Token Management
Complete JWT token handling with encryption support.
6. CustomTime Class - Advanced Date/Time Utilities
Powerful date and time manipulation with timezone support.
7. Middleware System
FastAPI provides two middleware systems: App-level (global) and Router-level (route-specific) with aliasing support.
App-Level Middleware (Global)
Router-Level Middleware (Route-Specific)
Key Differences:
- App-level: Global, no aliasing, runs before route matching
- Router-level: Route-specific, supports aliasing, runs after route matching
See Complete Middleware Guide for detailed documentation.
8. Utility Classes
StringMethods - String Utilities
ArrayMethods - Array Utilities
🔧 Advanced Usage
Complete Healthcare API Example
Rate Limited API with Custom Middleware
📚 Documentation
- API Reference - Complete API reference with method signatures
- Complete Middleware Guide - Comprehensive middleware documentation
- Route Groups Guide - Comprehensive route groups documentation
- WebSocket Documentation - Complete WebSocket implementation guide
- WebSocket Quick Reference - Quick reference for WebSocket patterns
- CustomTime Documentation - Advanced date/time manipulation guide
- Token Documentation - JWT token handling and security guide
- Utilities Documentation - StringMethods and ArrayMethods utilities
- Examples:
examples/
- Working examples for all features - Tests:
test/
- Compatibility and functionality tests
🔒 Security Features
- JWT Token Security: RSA encryption support, token refresh, expiry validation
- Rate Limiting: Revolutionary auto-fallback rate limiting with Redis → File fallback chain, zero downtime, and transparent operation
- Input Validation: Request data validation with custom rules
- CORS Support: Cross-origin request handling
- Header Security: Secure header management and validation
- Middleware Pipeline: Security middleware for authentication and authorization
🚀 Performance
- Efficient Routing: Optimized route matching with regex compilation
- Middleware Caching: Smart middleware resolution and caching
- Memory Management: Careful memory usage in group handling
- Streaming Support: Memory-efficient streaming responses
- Singleton Pattern: Efficient application lifecycle management
🔄 Migration and Compatibility
From Version 1.0.x to 1.1.x
✅ Zero Breaking Changes - All existing code continues to work:
Accessing New Features
🛠 Best Practices
1. Route Organization
2. Middleware Management
3. Error Handling
4. Response Consistency
🆕 Recent Improvements (v2.3.1)
App Class Refactoring & Clean Architecture
The App class has been completely refactored to eliminate duplicate methods and provide a cleaner, more maintainable architecture:
✅ What Was Improved:
- Removed Duplicate Methods: Eliminated redundant rate limiting methods that duplicated RateLimiter functionality
- Clean Separation of Concerns: App class now focuses on high-level application logic, RateLimiter handles all storage details
- Automatic Rate Limiting: Once configured with
setRateLimit()
, rate limiting is automatically enforced for every request - Better Performance: No more duplicate IP detection or storage logic
- Easier Maintenance: Changes to rate limiting only need to be made in one place
🔧 How It Works Now:
🎯 Benefits:
- Zero Client Code Changes: Your existing applications work without modification
- Better Performance: Automatic storage fallback (Redis → File)
- Cleaner Code: No more duplicate methods or redundant logic
- Easier Debugging: Clear separation between App and RateLimiter responsibilities
- Future-Proof: Cleaner architecture makes future enhancements easier
📚 Documentation:
- App Class Guide - Complete App class documentation
- Auto-Fallback Rate Limiting - Advanced rate limiting features
- Rate Limiting Quick Reference - Quick setup guide
🔍 Troubleshooting
Common Issues
-
Middleware Not Executing
-
Controller Not Found
- Route Parameters Not Working
🤝 Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
📚 Documentation
- WebSocket Documentation - Comprehensive WebSocket guide with examples
- WebSocket Quick Reference - Quick reference for common patterns
- Route Groups Documentation - Advanced routing with groups and middleware
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🔗 Links
- GitHub: https://github.com/imransaadullah/fast-api
- Packagist: https://packagist.org/packages/progrmanial/fast-api
- Issues: https://github.com/imransaadullah/fast-api/issues
FastAPI Framework - Making PHP API development fast, simple, and powerful! 🚀