Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: url_to() does not take into account the default namespace #5042

Closed
ivanBell199 opened this issue Aug 30, 2021 · 8 comments · Fixed by #5936
Closed

Bug: url_to() does not take into account the default namespace #5042

ivanBell199 opened this issue Aug 30, 2021 · 8 comments · Fixed by #5936
Labels
bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@ivanBell199
Copy link
Contributor

ivanBell199 commented Aug 30, 2021

Describe the bug
The example from the docs echo url_to('Home::index'); does not work. Instead it needs to be url_to('App\Controllers\Home::index') .

However if I have a folder inside "Controllers" I still cannot get the path. For example, url_to('App\Controllers\Admin\Categories::index') throws error Controller or its method is not found: App\Controllers\Admin\Categories::index
Am I missing something?

CodeIgniter v4.1.3

@ivanBell199 ivanBell199 added the bug Verified issues on the current code behavior or pull requests that will fix them label Aug 30, 2021
@sfadschm
Copy link
Contributor

The first argument of the function should be a class and function name,not a path. The example works for a class Home with method index. In your case , the class name needs to be fully qualified, i.e. you should provide the complete class name including the namespace.

@ivanBell199
Copy link
Contributor Author

I am sorry. Didn't figure out that url_to() only works if the route is stated insite Config/Routes.

@szajens
Copy link

szajens commented Apr 28, 2022

the bug still has not been fixed, you have to patch it yourself

@kenjis kenjis removed the bug Verified issues on the current code behavior or pull requests that will fix them label Apr 29, 2022
@kenjis
Copy link
Member

kenjis commented Apr 29, 2022

This seems a bug in the documentation.

  1. The first argument of the function should be a fully qualified classname and function name
  2. This function uses reverse routing, that is you need to define the route.

@szajens
Copy link

szajens commented Apr 29, 2022

This seems a bug in the documentation.

  1. The first argument of the function should be a fully qualified classname and function name
  2. This function uses reverse routing, that is you need to define the route.

You may be right. But look at the routes->add() declaration, right there $routes->add('blog/joe', 'Blogs::users/34'); there no namespace

@kenjis
Copy link
Member

kenjis commented Apr 29, 2022

@szajens You have a point. The behaviors are not consistent.

@kenjis kenjis added the bug Verified issues on the current code behavior or pull requests that will fix them label Apr 29, 2022
@kenjis kenjis reopened this Apr 29, 2022
@kenjis
Copy link
Member

kenjis commented Apr 29, 2022

@szajens I sent a PR to fix. #5936

@kenjis kenjis changed the title Bug: url_to() throws "Controller or its method is not found" Bug: url_to() does not take into account the default namespace Apr 29, 2022
@szajens
Copy link

szajens commented Apr 29, 2022

Cool, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants