PHP code example of alanalbert / imi-route

1. Go to this page and download the library: Download alanalbert/imi-route 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/ */

    

alanalbert / imi-route example snippets



namespace ImiApp;

use Imi\Main\AppBaseMain;
  
class Main extends AppBaseMain
{
  public function __init()
  {
      \Alan\ImiRoute\Route::init(); // Add this line
  }

}

/**
 * @var $router Route
 */

use Alan\ImiRoute\Route;
use ImiApp\ApiServer\Controller\IndexController;
use ImiApp\ApiServer\Middleware\Test2Middleware;
use ImiApp\ApiServer\Middleware\TestMiddleware;

$router->group(['middleware' => TestMiddleware::class], function (Route $router) {

    $router->group(
        [
            'middleware' => Test2Middleware::class, 
            'ignoreCase' => true, 
            'prefix' => 'prefix'
        ], function (Route $router) {
        $router->get('hi', 'ImiApp\ApiServer\Controller\IndexController@index');
    });

    $router->any('/hi/api/abc', [IndexController::class, 'index']);

    $router->any('/hi/api/{time}', [IndexController::class, 'api']);

});

$router->group(['prefix' => 'prefix'], function (Route $router) {
    $router->get('/TEST/{time}', [IndexController::class, 'api']);
});