PHP code example of exgalibas / gin

1. Go to this page and download the library: Download exgalibas/gin library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

exgalibas / gin example snippets


use \Exgalibas\Gin\Gin;

$route = new Gin();

//example, match get url "post/10/create", call_user_func(["post", "create"], ["id" => 10])
$route->get("<class:(post|comment)>/<id:(\d+)>/<function:(create|update|delete)>", '<class>|<function>');

//delete route rule
$route->deleteRule("<class:(post|comment)>/<id:(\d+)>/<function:(create|update|delete)>");

//example, match post url "exgalibas/login/10", call closure function([id=>10])
$route->post("exgalibas/login/<id:(\d+)>", function($params){...})

//example, match get url "exgalibas/login/joker", call login(["name" => "joker"])
$route->get("exgalibas/login/<name:joker>", "login")

//parse the request
$route->dispatch();