Skip to content

Bug: router service adds backslash to controllername if route is configured #2520

Description

@chriseilander

Describe the bug
When a route isn't defined, the controllerName() function in service('router') returns an expected string like 'App\Controllers{controllername}'. But when a route is defined in the routes.php it also returns an extra \ like '\App\Controllers{controllername}'.

CodeIgniter 4 version
CodeIgniter 4 RC 3 zip version
CodeIgniter 4 Dev starter composer
CodeIgniter 4 App starter composer

Affected module(s)
Probably the router service

Expected behavior, and steps to reproduce if appropriate
Let the namespace define the route, and return the controller name using
$router = service("router"); echo $router->controllerName();
It should return the namespace of the controller with the name.

Now define the route in routes.php, and the same code will return an \ with the namespace of the controller with the controllername.

I expected them to be the same.

Activity

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

Metadata

Metadata

Assignees

Labels

bugVerified issues on the current code behavior or pull requests that will fix them

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions