think\Route::patch PHP Method

patch() public static method

注册PATCH路由
public static patch ( string $rule, string $route = '', array $option = [], array $pattern = [] ) : void
$rule string 路由规则
$route string 路由地址
$option array 路由参数
$pattern array 变量规则
return void
    public static function patch($rule, $route = '', $option = [], $pattern = [])
    {
        self::rule($rule, $route, 'PATCH', $option, $pattern);
    }

Usage Example

Example #1
0
 public function testRegister()
 {
     $request = Request::instance();
     Route::get('hello/:name', 'index/hello');
     Route::get(['hello/:name' => 'index/hello']);
     Route::post('hello/:name', 'index/post');
     Route::put('hello/:name', 'index/put');
     Route::delete('hello/:name', 'index/delete');
     Route::patch('hello/:name', 'index/patch');
     Route::any('user/:id', 'index/user');
     $result = Route::check($request, 'hello/thinkphp');
     $this->assertEquals([null, 'index', 'hello'], $result['module']);
     $this->assertEquals(['hello' => true, 'user/:id' => true, 'hello/:name' => ['rule' => 'hello/:name', 'route' => 'index/hello', 'var' => ['name' => 1], 'option' => [], 'pattern' => []]], Route::rules('GET'));
     Route::rule('type1/:name', 'index/type', 'PUT|POST');
     Route::rule(['type2/:name' => 'index/type1']);
     Route::rule([['type3/:name', 'index/type2', ['method' => 'POST']]]);
     Route::rule(['name', 'type4/:name'], 'index/type4');
 }