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

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

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



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?

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

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.

Yes, we can do that!

Theme © iAndrew 2016 - Forum software by © MyBB