Download the PHP package effectra/router without Composer
On this page you can find all versions of the php package effectra/router. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package router
Effectra Router Library
Effectra PHP Router is a lightweight and flexible routing library for PHP applications. It provides a convenient way to define routes and dispatch incoming requests to the appropriate controllers or callbacks.
Installation
You can install the Effectra PHP Router library via Composer. Run the following command in your project directory:
Usage
To get started with Effectra PHP Router, follow these steps:
-
Include the autoloader if you haven't already done so:
-
Import the necessary classes:
-
Create an instance of the
Route
class: -
Define routes using the available methods:
- Dispatch the incoming request:
Route Methods
The Route
class provides several methods to define routes:
get($pattern, $callback)
: Defines a GET route.post($pattern, $callback)
: Defines a POST route.put($pattern, $callback)
: Defines a PUT route.delete($pattern, $callback)
: Defines a DELETE route.patch($pattern, $callback)
: Defines a PATCH route.options($pattern, $callback)
: Defines an OPTIONS route.any($pattern, $callback)
: Defines a route that matches any HTTP method.register($method, $pattern, $callback)
: Defines a custom route with a specific HTTP method.routes()
: Returns an array of defined routes.
Middleware
The Route
class supports middleware for route groups. You can use the middleware
method to add middleware to a group of routes:
Error Handling
The Route
class provides methods to handle 404 Not Found and 500 Internal Server Error responses:
Contributing
Contributions to the Effectra PHP Router library are welcome! If you encounter any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request.
License
The Effectra PHP Router library is open-source software licensed under the MIT license.
All versions of router with dependencies
psr/http-message Version ^1.1 || ^2.0
psr/http-server-handler Version ^1.0
psr/http-server-middleware Version ^1.0
bmt/plural-converter Version ^1.0
effectra/http-server-handler Version ^2.0
effectra/http-message Version ^1.0
psr/container Version ^2.0