定制 tigress/router 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tigress/router

最新稳定版本:2025.12.09.0

Composer 安装命令:

composer require tigress/router

包简介

Tigress router library

README 文档

README

The Router module of the Tigress Framework

Installation

You can create a new Tigress project by using composer.

composer create-project tigress/tigress <project_name>

Documentation

The Router is automatically loaded by the Core module.

Usage

The Router is used to define routes for your application. You can define routes in the 'config/routes.json' file.

Example

{
  "routes": [
    {
      "request": "GET",
      "path": "/",
      "controller": "HomeController",
      "method": "index"
    },
    {
      "request": "GET",
      "path": "/user/{id}",
      "controller": "UserController",
      "method": "show"
    },
    {
      "request": "POST",
      "path": "/user",
      "controller": "UserController",
      "method": "store"
    }
  ]
}

Route Parameters

You can define route parameters by using curly braces {} in the path. The parameters will be passed to the controller method as an array of arguments.

Example

{
  "routes": [
    {
      "request": "GET",
      "path": "/user/{id}",
      "controller": "UserController",
      "method": "show"
    }
  ]
}

In the above example, the id parameter will be passed to the show method of the UserController as an argument. In the controller you can access the parameter like this:

public function show($args) {
  // $args->id will contain the value of the 'id' parameter
}

Route Request Methods

You can define the request method for the route by using the request key in the route definition. The request method can be 'GET', 'POST', 'PUT', 'PATCH', 'DELETE' or 'OPTIONS'.

Route Controller

You can define the controller and method to be called for the route by using the controller and method keys in the route definition.

统计信息

  • 总下载量: 114
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2024-06-28