Documentation Index
Fetch the complete documentation index at: https://mintlify.com/MonishAMPT/fastroute-code/llms.txt
Use this file to discover all available pages before exploring further.
Introduction
FastRoute supports all standard HTTP methods, allowing you to build complete RESTful APIs. Each route can respond to specific HTTP methods, and the same URI can have different handlers for different methods.Supported HTTP Methods
FastRoute provides helper methods for common HTTP verbs:Method-Specific Routes
The same URI path can respond differently based on the HTTP method:Complete Example
Here’s a complete example showing multiple HTTP methods:routes/api.php
Request Dispatching
The dispatcher automatically routes requests based on the HTTP method:index.php
Method Not Allowed
FastRoute automatically handles cases where a route exists but the HTTP method is not allowed:index.php
Working with POST Data
Access POST data in your handlers usingfile_get_contents('php://input'):
HTTP Method Reference
GET - Retrieve Resources
GET - Retrieve Resources
Used to retrieve data from the server. Should not modify any data.
POST - Create Resources
POST - Create Resources
Used to create new resources on the server.
DELETE - Remove Resources
DELETE - Remove Resources
Used to delete resources from the server.
addRoute() - Any Method
addRoute() - Any Method
Generic method to add routes with any HTTP method.
RESTful Pattern
Follow RESTful conventions for HTTP methods:GET
Retrieve data without side effects
POST
Create new resources
PUT
Update existing resources
DELETE
Remove resources
Best Practices
Use Appropriate Methods
Match HTTP methods to their semantic meaning (GET for retrieval, POST for creation, etc.)
Next Steps
REST API
Build complete RESTful APIs with CRUD operations
Dynamic Parameters
Combine HTTP methods with dynamic route parameters