Welcome Guest, Not a member yet? Register   Sign In
Using variables as the controller name for routes
#11

(This post was last modified: 07-16-2021, 08:06 AM by paulbalandan.)

(07-16-2021, 04:22 AM)John_Betong Wrote: @eril46,

https://codeigniter.com/user_guide/incom...llers.html

Quote:Important

Controller class names MUST start with an uppercase letter and ONLY the first character can be uppercase.

Note to Development Team:
BaseController.php does not conform to the above restrictions?
Hi!

1) BaseController is an abstract controller class. Being such, it cannot be used for routing purposes, so basically it's exempted from the restrictions.
2) If you're using the auto-routing feature, this quote MUST be followed strictly.
3) If you are instead defining each route explicitly, no need to follow this but we use and recommend the PascalCase naming convention (actually used for all classes in the framework).

(06-11-2021, 11:51 AM)eri146 Wrote: Hello, I have a POST request. For example
/admin/something/(:any)

And I would like to use (:any) as a class variable. For example
$routes->post('/admin/something/(:any)', 'admin/$1::methodname');

Using $1 does not work under any circumstance and it seems that this slash is being trimmed in the Router.php system file.
How can I use it as a variable? Additionally, how could I also use the method as a variable after the double colons? :: For example:
$routes->post('/admin/(:any)/(:any)', 'admin/$1::$2');

Thank you!

In theory, this is workable BUT NOT recommended. This practice can pose a lot of complications in the future. Foremost, you have to make sure all possible combinations are available classes and methods, otherwise you have to devise your own failover. Simply do not do this.
Reply
#12

Yes, we can do that!
Reply
#13

(07-19-2021, 11:04 AM)Escuela de Letras Wrote: Yes, we can do that!

You can do it but you'd have to re-write certain system config files to allow it. It's not worth the headache. Just use the systems as it's designed, for less headache and optimum security.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB