Download the PHP package ilias/rhetoric without Composer
On this page you can find all versions of the php package ilias/rhetoric. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ilias/rhetoric
More information about ilias/rhetoric
Files in ilias/rhetoric
Package rhetoric
Short Description Package addressed to handling routes with PHP
License MIT
Homepage https://github.com/iloElias/rhetoric
Informations about the package rhetoric
Rhetoric Router @IloElias
This PHP router system allows you to define and manage your application's routes in a simple and organized manner, inspired by Laravel's routing system.
Installation
To install the package, add it to your composer.json file:
Or simply run the terminal command
Then, run the following command to install the package:
Usage
Step 1: Define Your Routes
Create a file to define your routes, for example, in your project root folder, routes.php:
Step 2: Set Up Your Router
In your application's entry point, typically index.php, set up the router to handle incoming requests:
Step 3: Create Controllers
Create your controller classes to handle the requests. For example, create IndexController.php:
Similarly, create other controller classes like AssetController.php and DebugController.php as needed.
Step 4: Handling Middleware (Optional)
If you want to use middleware, create a middleware class implementing Ilias\Rhetoric\Middleware\Middleware:
Then, apply middleware to your routes or route groups:
Step 5: Dispatching Routes
Using the Request static method, dispatch(), you can handle the current route:
Dynamic params
Using the Request static attribute, $params, you can access an associative array:
When you access the route http://your.dev.api.com/user/iloElias/config, the params will be stored in Request::$params as:
Explanations
-
::classIs recommended to use the static reference to your class, so te code does know exactly which class to use