Download the PHP package zanko-khaledi/php-simple-router without Composer
On this page you can find all versions of the php package zanko-khaledi/php-simple-router. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package php-simple-router
php-simple-router
this light weight router library can be useful for small php web projects or building you'r api.
installation
Usage
You can use this router like below
Use Controller instead of callback functions
However you would be able to use dynamic route parameters
Router Collection
Add router collection for modular routing
Notice
If you use RouterCollection
class for load your route files , you have to avoid call Router::executeRoutes()
in your route files because this method calling once you invoke executeRoutesFrom()
method from RouterCollection
so just do like this :
Request methods
You can use only this request methods to handle you're api
Middleware
Create a class for example AuthMiddleware that implements IMiddleware contract
After middleware has been created you should register it on you're router
Group
you can use group route binding
Also you would be able to bind middlewares to group method
You can also use subdomains in group
method like block code below
By default you're host name is localhost you would be able to change it in .env
file on root of you're project for example
after setting HOSTNAME
variable in .env
file you must to add this line of code inside of index.php
file in root of your project
or in public directory
Testing
You can test you're api like code block above. some test api :
if you familiar to PHPUnit test framework and Guzzle/Http library you could test you're api without Router test api by default.
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
License
All versions of php-simple-router with dependencies
guzzlehttp/guzzle Version ^7.0
phpunit/phpunit Version 9.*
vlucas/phpdotenv Version ^5.5