How robsonvleite/router works
CoffeeCode Router is a small PHP routing component. An incoming request reaches the application’s Router, which registers RESTful routes and dispatches by HTTP method and path; matching routes can apply middleware before invoking a callable or controller action with route data. The library also supports method spoofing, named-route URL generation, and redirects. Example controllers and middleware illustrate these features. The graph follows the sampled core sources and README; example controller implementations not excerpted are included only where the source index or README identifies their use.
Main entry points: index.php Example entry point · RouterTrait.php Middleware gate · Middlewares.php Middleware examples · Router.php Router API
Components 19
Routing core
- Router API
src/Router.php - Dispatch state
src/Dispatch.php - Route registration
src/RouterTrait.php - Named URLs
src/RouterTrait.php - Redirects
src/Dispatch.php
Request execution
- Route matching
src/Dispatch.php - Method spoofing
src/RouterTrait.php - Middleware gate
src/RouterTrait.php - Handler execution
src/RouterTrait.php
Example application
- Example entry point
exemple/controller/index.php - Coffee controller
exemple/controller/Test/Coffee.php - Name controller
exemple/controller/Test/Name.php - Middleware examples
exemple/controller/Http/Middlewares.php - Guest middleware
exemple/controller/Http/Guest.php - User middleware
exemple/controller/Http/User.php - Group middleware
exemple/controller/Http/Group.php - Spoofing example
exemple/spoofing/index.php
Other components
- HTTP request
- HTTP response
Connections 24
- HTTP request → Example entry point: enters
README.md - Example entry point → Router API: configures
exemple/controller/index.php - Router API → Dispatch state: extends
src/Router.php - Router API → Route registration: registers routes
src/Router.php - Route registration → Method spoofing: reads form data
src/RouterTrait.php - Example entry point → Dispatch state: dispatches
exemple/controller/index.php - Dispatch state → Route matching: matches request
src/Dispatch.php - Route matching → Handler execution: executes match
src/Dispatch.php - Handler execution → Middleware gate: checks middleware
src/RouterTrait.php - Handler execution → Coffee controller: invokes action
- Handler execution → Name controller: invokes action
- Example entry point → Middleware examples: uses middleware constants
exemple/controller/index.php - Middleware examples → Guest middleware: references
exemple/controller/Http/Middlewares.php - Middleware examples → User middleware: references
exemple/controller/Http/Middlewares.php - Middleware examples → Group middleware: references
exemple/controller/Http/Middlewares.php - Middleware gate → Guest middleware: runs middleware
- Middleware gate → User middleware: runs middleware
- Middleware gate → Group middleware: runs middleware
- Example entry point → Named URLs: uses named routes
exemple/controller/index.php - Example entry point → Redirects: redirects errors
exemple/controller/index.php - Named URLs → Redirects: resolves route
src/Dispatch.php - Example entry point → HTTP response: serves result
- Spoofing example → Router API: registers verbs
exemple/spoofing/index.php - Spoofing example → Dispatch state: dispatches
exemple/spoofing/index.php