PHP Classes
elePHPant
Icontem

Kolserdav PHP Router Library: Route requests by path to given action controllers

Recommend this page to a friend!
  Info   View files Example   View files View files (13)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2018-06-14 (1 year ago) RSS 2.0 feedNot yet rated by the usersTotal: 87 All time: 9,365 This week: 344Up
Version License PHP version Categories
router 1.0MIT/X Consortium ...5HTTP, PHP 5, Libraries
Description Author

This package can route requests by path to given action controllers.

It parses a configuration file to extract the definition of the patterns of paths of HTTP requests supported by a Web application.

The package can call controller classes defined in the configuration file to map each pattern of HTTP request path to an action that your Web application supports.

  Performance   Level  
Name: Sergey Kol'miller <contact>
Classes: 2 packages by
Country: Russian Federation Russian Federation
Age: 36
All time rank: 4125112 in Russian Federation Russian Federation
Week rank: 747 Up24 in Russian Federation Russian Federation Up

 

Details

The simple route module.

_Installation_

~$composer require kolserdav/router

[Make catalog src/Controller ... Copy file src/Controller/TestController.php ... Copy file src/Controller/ErrorPage.php ... Rewrite namespaces ... Make catalog /config/route ... Copy file /config/route/routes.yaml] or call...

~$php vendor/kolserdav/router/install

_Using_

You must use a single access point.

index.php

require 'vendor/autoload.php';

use Avir\Router\Route;

$router = new Route();
$router->route();

Add your routes in /config/route/routes.yaml

index :                                           
      path : /                                    
      controller: IndexController::indexPublic    
users :
      path : /users/
      controller : User\UserConroller::usersPublic

Create custom controllers with methods. _For example:_ IndexController::indexPublic User\UserConroller::usersPublic

When coinciding field 'path' with URI, the specified controller will be turned on. If URI contains of number, it will be available in the controller as...

class SomeClass
{
    public $id
    
    public function someFunction(){
        $this->id;
    }
} 

Also you can transfer parameters to URI

http://some.domains/some/uri/path?one=param1&two=param2&three=param3 //...

and catch them in the controller as

class SomeClass
{
    public $params;
    
    public function someFunction(){
        $this->params; //[ one : param1, two : param2, three : param3 ]
    }
} 

It's all... Very simple!

  Files folder image Files  
File Role Description
Files folder imageconfig (1 directory)
Files folder imagesrc (3 files, 3 directories)
Files folder imagetests (1 directory)
Plain text file composer.json Data Auxiliary data
Plain text file install Example Example script
Plain text file README.md Doc. Documentation

  Files folder image Files  /  config  
File Role Description
Files folder imageroute (1 file)

  Files folder image Files  /  config  /  route  
File Role Description
  Plain text file routes.yaml Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
Files folder imageController (2 files)
Files folder imageListener (1 file)
Files folder imageRespondent (2 files)
  Plain text file Driver.php Class Class source
  Plain text file Route.php Class Class source
  Plain text file RouteStation.php Class Class source

  Files folder image Files  /  src  /  Controller  
File Role Description
  Plain text file ErrorPage.php Class Class source
  Plain text file TestController.php Class Class source

  Files folder image Files  /  src  /  Listener  
File Role Description
  Plain text file Filter.php Class Class source

  Files folder image Files  /  src  /  Respondent  
File Role Description
  Plain text file responder.php Aux. Auxiliary script
  Plain text file Teletype.php Class Class source

  Files folder image Files  /  tests  
File Role Description
Files folder imageroutetest (1 file)

  Files folder image Files  /  tests  /  routetest  
File Role Description
  Plain text file Test.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:87
This week:0
All time:9,365
This week:344Up