Skip to content

Upgrade to nikic/fast-route v2 #358

@philipobenito

Description

@philipobenito

Upgrade the FastRoute dependency from ^1.3 to v2 when it reaches stable.

Current state:

  • league/route depends on nikic/fast-route ^1.3 (released 2018)
  • FastRoute v2.0.0-beta1 was released March 2024 but has not progressed to stable

What v2 changes:

  • dispatch() returns Matched|NotMatched|MethodNotAllowed result objects instead of arrays
  • RouteCollector replaced by ConfigureRoutes interface
  • GroupCountBased dispatcher marked as @final (breaks our current inheritance)
  • Built-in GenerateUri interface for reverse routing
  • Built-in Cache interface
  • PHP 8.1+ minimum with strict types throughout

Required work:

  • Replace Dispatcher inheritance with composition (the Dispatcher currently extends GroupCountBased)
  • Adapt to new result object types in matchRequest() and dispatchRequest()
  • Update Router::prepareRoutes() for the new ConfigureRoutes API
  • Potentially leverage v2's built-in URI generation for reverse routing (Reverse routing / URL generation from named routes #355)
  • Potentially leverage v2's caching alongside our index-based approach

Prerequisite: FastRoute v2 reaching a stable release.

Target: 8.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions