PHP Version
8.3
CodeIgniter4 Version
4.6.3
CodeIgniter4 Installation Method
Composer (using codeigniter4/appstarter)
Which operating systems have you tested for this bug?
Windows, Linux
Which server did you use?
apache
Database
No response
What happened?
When defining a custom placeholder in CodeIgniter 4 routing, the routes that use this placeholder do not execute the filters assigned to them. The framework seems to completely skip the filter layer for those routes.
Steps to Reproduce
- Create a custom placeholder in app/Config/Routes.php:
$routes->addPlaceholder('code', '[A-Z]{3}[0-9]+')
- Define a route using this placeholder and apply filters:
$routes->get('test/(:code)', 'TestController::index', ['filter' => 'auth']);
- Access a URL matching the pattern:
/test/ABC123
-
Observe that the auth filter does not run.
-
Check the defined filter from the listed routes using the php spark routes command.
| Method | Route | Name | Handler | Before Filters | After Filters
| GET | test/([A-Za-z]+-[A-Za-z0-9]+) | » | \App\Controllers\Test::index/$1 | <unknown> | <unknown>
Additional Notes
- Filters work correctly when using standard placeholders.
- The issue appears only when using custom placeholders created via addPlaceholder().
Expected Output
Filters defined for a route that uses a custom placeholder should run normally, the same way they run with the default placeholders ((:num), (:segment), etc.).
Anything else?
No response