Skip to content

Back references not working in route #1761

Description

@tcrawf

Back-references not working in route

Guidance from user manual
Note: If you use back-references you must use the dollar syntax rather than the double backslash syntax. A typical RegEx route might look something like this:
$routes->add('products/([a-z]+)/(\d+)', '$1::id_$2');

Code
Routes.php file:
$routes->get('products/([a-z]+)/(:num)','$1::view/$2');

Action
Go to http://site.test/products/trucks/5 on local development machine

Expected behaviour (based on user manual)
Load view() method on Trucks controller called with the numerical product id.

Actual behaviour
404 Error
Controller or its method is not found: \App\Controllers$1::view
The back-reference is not being converter from $1 to Trucks

CodeIgniter 4 version
v4.0.0-alpha.5

Affected module(s)
\Codeigniter\Router

Context

  • OS: Ubuntu 18.04
  • Web server [e.g. Apache 2.4.29]
  • PHP version [e.g. 7.2.10]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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