PHP code example of phalapi / fast-route

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

    

phalapi / fast-route example snippets


	/**
	 * 扩展类库 - 快速路由配置
	 */
    'FastRoute' => array(
         /**
          * 格式:array($method, $routePattern, $handler)
          *
          * @param string/array $method 允许的HTTP请求方式,可以为:GET/POST/HEAD/DELETE 等
          * @param string $routePattern 路由的正则表达式
          * @param string $handler 对应PhalApi中接口服务名称,即:?service=$handler
          */
        'routes' => array(
            array('GET', '/site/index', 'Site.Index'),
            array('GET', '/examples/curd/get/{id:\d}', 'Examples_CURD.Get'),
        ),
    ),



array('POST', '/user/{id:\d+}/{name}', 'handler2'),


use PhalApi\FastRoute\Handler;
use PhalApi\Response;

class MyHandler implements Handler {

    public function excute(Response $response) {
        // ... ...
    }
}

\PhalApi\DI()->fastRoute->dispatch(new MyHandler());