• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Magic routing for modules

#1
Lightbulb 
Hi,

Would it be possible to enable magic routing for modules ?
This will be much easier than defining all routes manually

The URL should be /acme/blog/list, fo example, where acme is the name of the module, blog the controller and list the method .

This feature is already available,for instance, in the HMVC extension (MX) of CodeIgniter 3.

Thanks in advance.

Fred
Reply

#2
Not sure how to do this with HMVC (never used it) but I will recommend defining your routes. It may seem "easier" to start, but it does not scale well at all. Your routes.php file ends up becoming a very good blueprint for any devs that might join the project later on.

If this is a pet/small project, it may not matter though.
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!
Reply

#3
I define all my routes in the module config folder route.php

I use a Group Closure to add them in makes it easier to do.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#4
Agree with @InsiteFX - you may define the routes yourself within the module using config/Routes.php. It isn't "magic" routing for the developer (though you can create them in bulk with wildcards or resource routes) but for the user including the module they shouldn't need to do anything.
Here's an example from one of my modules that, when installed, will instantly make https://example.com/workflows (among others) available on the site:
https://github.com/tattersoftware/codeig...Routes.php
Reply

#5
(07-24-2019, 05:19 PM)InsiteFX Wrote: I define all my routes in the module config folder route.php

I use a Group Closure to add them in makes it easier to do.

Hi @InsiteFx,

Do you mean you were able to load the routes from the active module?

Actually, I want to load the routes from the active module.

I tried by looking into the HMVC MX_Router.php it seems the system is getting the active module name after the routes are initialized.

Can you please help me with this?

Thanks!
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.