PHP Classes

Wepesi PHP Router with Parameters: Route requests to functions or controller classes

Recommend this page to a friend!
  Info   View files Example   View files View files (10)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 42 This week: 1All time: 10,799 This week: 560Up
Version License PHP version Categories
wepesi_router 1.0.0The PHP License5HTTP, PHP 5, Design Patterns
Description 

Author

This package can route requests to functions or controller classes.

It can register several URL patterns that the developer wants that his Web application handles.

The package associates controller classes or callback functions to handle those requests.

The callback functions may take parameters with values extracted from the current HTTP request URL.

The package may call the controller class by invoking a specific class function defined in the registered URL pattern associated with the controller class.

The package can also process the current HTTP request and invoke the callback function or controller class associated with the URL pattern that matches the current URL pattern.

Picture of Boss Ibrahim Mussa
  Performance   Level  
Name: Boss Ibrahim Mussa <contact>
Classes: 13 packages by
Country: Congo Congo
Age: ???
All time rank: 29051 in Congo Congo
Week rank: 109 Up1 in Congo Congo Equal
Innovation award
Innovation award
Nominee: 5x

Example

<?php
use Wepesi\App\Core\Router;
$route=new Router();
/**
 * call the route
 */
$route->get("/",function(){
    echo
"<h3>welcome to WEPESI ROUTING</h3>";
});
$route->get("/welcom", "welcomController#welcom");
$route->get("/welcom/:name",function($name){
    echo
"your name is : $name";
});
$route->run();


Details

WEPESI_ROUTER

This is a simple php module that will help you write clear route in php application

INTRODUCTION

wepesi is a simple mini-framawork that help to create simple wep application using OOP logic. it provide : - routing - validation for more : https://github.com/bim-g/wepesi_validation - token (generator & validator) - ORM design for mySQL for more : https://github.com/bim-g/Wepesi-ORM - session management - ... you can find more about comple module on : https://github.com/kivudesign/Wepesi-Quick

INTEGRATION

create an instance of the router, that will help implemet request method, assume that you should call the method run at the end of all the method to take into consideration all the route define.

    $router=new Router();
    $router->get("/",function(){
        echo "<h3>welcome to WEPESI ROUTING</h3>";
    });
    $router->run()

  • GET: while define a get method, you provide the route name to reach and the action to execute. that action can be a `callable` function or method of a class is define on the class folder.

        $router->get('/',function(){
            echo "welcome to the root";
        });
    
        $router->get("/hello","user#sayHello")
    

    as you can seen in the example below, we want to reach the route `localhost/hello` and the action will be `hello` a method define on the class user `user#sayHello`. in case this method is not define that class it will not passe.


  Files folder image Files  
File Role Description
Files folder imageclass (2 directories)
Files folder imageconfig (2 files)
Files folder imagepublic (1 file)
Files folder imageroute (1 file)
Accessible without login Plain text file .htaccess Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  class  
File Role Description
Files folder imageApp (2 files)
Files folder imagecontroller (1 file)

  Files folder image Files  /  class  /  App  
File Role Description
  Plain text file Route.php Class Class source
  Plain text file Router.php Class Class source

  Files folder image Files  /  class  /  controller  
File Role Description
  Plain text file welcomController.php Class Class source

  Files folder image Files  /  config  
File Role Description
  Accessible without login Plain text file global.php Aux. Auxiliary script
  Accessible without login Plain text file init.php Aux. Auxiliary script

  Files folder image Files  /  public  
File Role Description
  Accessible without login Plain text file index.php Aux. Auxiliary script

  Files folder image Files  /  route  
File Role Description
  Accessible without login Plain text file index.php Example Example script

 Version Control Unique User Downloads Download Rankings  
 100%
Total:42
This week:1
All time:10,799
This week:560Up