企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
## 配置文件 ### 推荐使用 [Annotation格式路由](Annotation格式路由.md) 自动生成路由规则 GFPHP 的路由配置文件目录为 ``Router``,添加路由规则需要添加文件``Router/项目名/路由文件.php``,其中项目名称是初始化项目时``GFPHP::init('项目名')`` 中的名称. ## 配置写法 路由规则的写法是以正则方式,规则中匹配到的值会传入到方法. #### 全部请求 此种配置方式,将会匹配所有的请求方式. ``` \GFPHP\Router::all('index.html','System/Home@index'); ``` #### GET请求 ``` \GFPHP\Router::get('index.html','System/Home@index'); ``` #### POST请求 ``` \GFPHP\Router::post('index.html','System/Home@index'); ``` #### PUT请求 ``` \GFPHP\Router::put('index.html','System/Home@index'); ``` #### DELETE请求 ``` \GFPHP\Router::delete('index.html','System/Home@index'); ``` #### HEAD请求 ``` \GFPHP\Router::head('index.html','System/Home@index'); ``` ### 将路由注册到匿名函数 ``` \GFPHP\Router::all('index.html',function(){ return 'Hello GFPHP'; }); ``` ### 匹配传值 ``` //-- 指向Action \GFPHP\Router::all('article-(\d+).html','System/Article@view'); //-- 匿名写法 \GFPHP\Router::all('article-(\d+).html',function($article_id){ return '文章ID:' . $article_id; }); ```