routing-interop/route-definition 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

routing-interop/route-definition

Composer 安装命令:

composer require routing-interop/route-definition

包简介

Abstract definition of a route

README 文档

README

Installation

$ composer require routing-interop/route

Usage

<?php

use Interop\Routing\Route\RouteCollection;

$routes = (new RouteCollection)
    ->get('/blog',        [BlogController::class, 'index'])
    ->get('/blog/{slug}', [BlogController::class, 'show'])
    ->post('/blog',       [BlogController::class, 'create'])
;

Thougts

  • Most routing libraries use the following route declaration format:

    addRoute(<HTTP method>, <path>, <callable handler>)
    
  • path can be a string, a regex, or a custom format. It usually contains all the variable parts or the path, the type constraints.

  • Each path part is a segment (typical URI language).

  • Simple string segments are static, while others are dynamic.

  • Other route constraints not contained in path:

    • Host
    • Scheme
    • Port
  • A dynamic segment can be optional and have a default value

  • Using a common static prefix for a bunch of routes is very useful

  • Declaring a group of routes with the same path but not the same method can be useful

  • What to do when no route is matched? Wrong URI, wrong method, ...
    It may be useful to add default workflow and responses.

  • Giving a name to routes seems deprecated. Wait... no, it isn't: how do we generate URIs without names!?

  • Content negotiation is not is the scope of routing

  • Parameter conversion (from /post/{slug} to controller(BlogPost $post)) is out of scope.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-03-19

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固