Reputation: 97
For some reasons, I do not want to access from url like examples.com/controller/method
. I want to force Codeigniter to use routes.php
instead. I do not want to use private
, protect
or _method
.
Please, help! I am using Codeigniter 3
Upvotes: 1
Views: 3786
Reputation: 21
I found a solution in Codeigniter 4, just go to routes and set autoroute to false
$routes->setAutoRoute(false);
Upvotes: 2
Reputation: 359
In codeigniter, the methods you write in controllers are to be accessed in the url that is its mvc structure. If you want to avoid a function in the controller to be seen in the url, simply make that function private/protected or prepend an _ in the function name.
private func_name
or
public _func_name
or
protected func_name
any of the options in your functions won't allow access to your functions in the url. If you want you controller function to be accessed by other subclasses, you ll need to make the function public or protected as required and to avoid it to be accessed by the url simply prepend an underscore _
Upvotes: 3