Download the PHP package torugo/router without Composer
On this page you can find all versions of the php package torugo/router. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download torugo/router
More information about torugo/router
Files in torugo/router
Package router
Short Description Simple route system using PHP Attributes
License MIT
Homepage https://github.com/vitor-hugo/router
Informations about the package router
Router
A simple PHP router system.
Uses the PHP Attributes feature.
Table of Contents
- Requirements
- Installing
- Usage
- Routing
- Registering Controllers
- Resolving the requests
- Auto Resolve
- Resolving manually
- Prefixing all routes
- Getting request data
- Responses
- Full example
- Tests
- With Makefile
- Manually
- Contribute
- License
Requirements
- PHP 8.2+
- Composer 2+ (Package manager)
- PHPUnit 11+ (Automated tests)
Installing
Usage
Routing
Registering Controllers
All controllers must use the Controller attribute.
Additionally you can register controllers individually.
Resolving the requests
Auto Resolve
Resolving manually
Prefixing all routes
If your API has a prefixed route like '/v1'
you can configure the router to handle it.
Getting request data
You can access the request data anywhere using the method getData()
from Torugo\Router\Request
.
Responses
When a controller method returns array it is converted to a Json string, other types are not converted.
Full example
-
Controller class
- Main app file "index.php"
Tests
With Makefile
To run the tests with make
use:
or with PHPUnit testdox
Manually
[!TIP]
- You will need to use two terminal windows to run the tests manually.
- All commands must be executed from the project root.
1. Start Test Server
In the first window terminal type:
2. Run the tests
In the second window, from the project root type:
Contribute
It is currently not open to contributions, I intend to make it available as soon as possible.
License
Router is licensed under the MIT License - see the LICENSE file for details.
All versions of router with dependencies
ext-mbstring Version *