ATK4 FastRoute: Process HTTP requests using configured routes

Recommend this page to a friend!
  Info   Example   View files (40)   Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 62 All time: 9,738 This week: 238
Version License PHP version Categories
atk4-fastroute 1.0.0MIT/X Consortium ...7HTTP, Design Patterns, PHP 7, Traits
Collaborate with this project Author

atk4-fastroute - github.com

Description

This package can process HTTP requests using configured routes.

It can configure one or more routes by specifying a URL pattern to match, HTTP methods, and code that should be called when the current HTTP request matches that route.

The package can also process the current HTTP request and call the code associated to the route that matches the current request URL.

Picture of Francesco Danti
  Performance   Level  
Name: Francesco Danti <contact>
Classes: 7 packages by
Country: Italy Italy
Age: 42
All time rank: 3651147 in Italy Italy
Week rank: 259 11 in Italy Italy
Innovation award
Innovation award
Nominee: 2x

Details

atk4-fastroute

Build Status Codacy Badge Coverage Status Test Coverage Maintainability

ATK4 integration with FastRoute

Still needs :

  • [x] more test for patterns route
  • [x] test for calls with extraparameters
  • [ ] check if can be simplified
  • [ ] add Translation as option - [ ] add slugging of routes
  • [ ] check if can be added MiddlewareInterface - [ ] to be executed by pattern (Another Router in Router that dispatch MW by route match) ? - [ ] to be executed per route (before handlingRoute)?
  • [ ] add comments to public methods!!!
  • [ ] add documentation

EXPERIMENTAL

Define routes : - RoutedCallable : as Callable - RoutedUI : as atk4/ui/* Class to be added to the App - RoutedMethod : as Class Method to be called like a controller

Routes can be serialized as array to allow loading from external file.

Using Interface implementation to define behaviour and needs of the class ( like flags ) :

- iBeforeRoutable : request method OnBeforeRoute which will be called right before OnRoute ( setting up app? ) - iAfterRoutable : request method OnAfterRoute which will be called right after OnRoute ( setup other elements? ) - iArrayable : have fromArray and toArray to be serializeable - iNeedAppRun : if is needed to call ->app->run() after Routing method calls

Next step

  • Having a collection of routes, that in the future can be translatable
  Files  
File Role Description
demos (6 files, 2 directories)
src (1 file, 4 directories)
tests (1 file)
.codeclimate.yml Data Auxiliary data
.coveralls.yml Data Auxiliary data
.phpmetrics.json Data Auxiliary data
.php_cs.dist Example Example script
.styleci.yml Data Auxiliary data
.travis.yml Data Auxiliary data
composer.json Data Auxiliary data
LICENSE Lic. License text
phpunit.xml Data Auxiliary data
README.md Doc. Documentation
renovate.json Data Auxiliary data

  Files  /  demos  
File Role Description
config (1 file)
static_assets (1 file)
   .htaccess Data Auxiliary data
   bootstrap.php Class Class source
   cached.php Class Class source
   index.php Class Class source
   static.php Example Example script
   using-config.php Example Example script

  Files  /  demos  /  config  
File Role Description
   routes.php Aux. Auxiliary script

  Files  /  demos  /  static_assets  
File Role Description
   test.css Data Auxiliary data

  Files  /  src  
File Role Description
Exception (3 files)
Handler (4 files, 1 directory)
Route (2 files)
View (3 files)
   Router.php Class Class source

  Files  /  src  /  Exception  
File Role Description
   StaticFileExtensionNotAllowed.php Class Class source
   StaticFileNotAllowedFolder.php Class Class source
   StaticFileNotExists.php Class Class source

  Files  /  src  /  Handler  
File Role Description
Contracts (7 files)
   RoutedCallable.php Class Class source
   RoutedMethod.php Class Class source
   RoutedServeStatic.php Class Class source
   RoutedUI.php Class Class source

  Files  /  src  /  Handler  /  Contracts  
File Role Description
   AfterRoutableTrait.php Class Class source
   BeforeRoutableTrait.php Class Class source
   iAfterRoutable.php Class Class source
   iArrayable.php Class Class source
   iBeforeRoutable.php Class Class source
   iNeedAppRun.php Class Class source
   iOnRoute.php Class Class source

  Files  /  src  /  Route  
File Role Description
   iRoute.php Class Class source
   Route.php Class Class source

  Files  /  src  /  View  
File Role Description
   AbstractView.php Class Class source
   MethodNotAllowed.php Class Class source
   NotFound.php Class Class source

  Files  /  tests  
File Role Description
   RouterTest.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:62
This week:0
All time:9,738
This week:238

For more information send a message to info at phpclasses dot org.