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

Issue with subfolder controller structure like admin folder #12

Closed
shri4ram opened this issue Aug 15, 2015 · 5 comments
Closed

Issue with subfolder controller structure like admin folder #12

shri4ram opened this issue Aug 15, 2015 · 5 comments

Comments

@shri4ram
Copy link

Hi
Iam first time using this advanced routing system on Codeigniter..
Something like regular ci, working code: $route['admin'] = 'admin/account/login'
After login, i need open another controller which is present on Admin folder. ie., admin/Dashboard.php

i placed below code:
Route::prefix('admin', function() {
Route::get('dashboard', 'admin/dashboard/method');
});

Test URL request something like:
http://localhost/ci/admin/dashboard/

Iam getting 404errors. (i placed htaccess code also remove index.php from url)
Please can suggest where i did wrong

@Patroklo
Copy link
Owner

Hi, sorry about the delay, I was on vacation.

About your problem, this example works fine for me. So. It can be a problem with the route index.php, or that the controller's file name it's "dashboard" instead of "Dashboard", or maybe you are not calling "Route::map()" ?

If everything's okay tell me and we will see what could be the specific problem.

@Patroklo
Copy link
Owner

Also, check it without the anonymous function like

Route::any('admin/dashboard', 'admin/dashboard/method');

It could be a problem with the php version and the anonymous functions?

@shri4ram
Copy link
Author

Hi Patroklo
Iam very sorry the delay..

Actually i have folder structure ike below
controllers/ some controllers list (frontend)
controllers/ admin/

  • account
  • dashboard
  • employees
    etc... (above 3 are in admin folder)

Now, take some scenario like, we need to show Dashboard after login.

Default codeigniter will works for the below link without placing any routes..
URL : http://localhost/ci/admin/dashboard/
Above link works fine without placing any routes on routes.php , Because both admin(folder) & dashboard (controller) exists..
($route['admin/dashboard'] = "admin/dashboard/index";) This line is not required for Default..

In the same way, is it possible with this codeigniter-static-laravel-routes library..
I mean, without placing this below line
Route::any('admin/dashboard', 'admin/dashboard/method');

This link should work: http://localhost/ci/admin/dashboard/
Reason for asking this was, need to add single link on routes.php as above line.

Is Below thing possible??
admin/ *, *, * etc...

Without breaking any links, is it possible to change Admin folder name ? ( Admin -to- sp-admin )
sp-admin/,,* -

@Patroklo
Copy link
Owner

Hi
Yes, you can make something like this

Route::any('admin/(:any)', 'admin/dashboard/$1');

And then every string in any will go to its method in Dashboard controller.

@Patroklo
Copy link
Owner

Obviously, if method doesnt exist, it will throw a error calling a method, not a 404, so its up to you to change that into a 404. I can suggest you to use a filter that detects if a method exist and if it doesnt, make a show_404();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants