Welcome Guest, Not a member yet? Register   Sign In
No Controller Call In Controller Anymore

Hi there,

I would like to make feature request to the thread named 'No Controller Call In Controller Anymore'.

I have created this for CodeIgnitor 3 and it would be nice to have it in the new version CI 4.

This is just an idea of how it's done :
Get the first registered numeric key

Separate it to segments -> path to class folder,file class,class method,method numeric data,other data
//Simple Examples :
//More complicated Examples :

//Note : ShowProfile is the class method and 365 is the Profile_ID
//If you try to have url like this :
this is not going to be working because it is based on ID

You can have look in my code :
Click here to see : "No Controller Call In Controller Anymore"
I know it's not maybe the ideal way of creating what i have done,because it's not actually accepting the id yet.

It actually still need some tweeking,which i will do soon or later.

Well and why i actually created this tweak ?

1. I've seen many people over the internet try to do it ...than they got's some issue with session.php or other issues,even i've got that issue when i was trying for example to have nice url when called controller in controller.Which CodeIgnitor is not designed for.

2. It is good to have a structure of the controllers to keep them more organised instead of have too many in one folder.

Incease if i forgot something i'll write it later.
I was writing this in rush.

Just to let you know that now classs "My_Router" it's working as it should.
It would be great if you intergrate this to the "CI_Router" core.

So how it's working? Lets start with the base.
Default old settings :


default url :

Default new settings :
after applying the code to the core it will automaticly redirect internet browser to the default_controller and it's default method.
So if user enter : PROTOCOL://your-site.extension/
it will directly become :

and that's not all.

The other thing is when developer of the app want to have controllers organised like so :

Lets just for now pretend that we are now creating a structure of the controllers and developing new application.

Simple view :
The developer change a setting in the default_controller to class "Web".
that means the url will look like this :

Next thing is that the developer want to act with user login for example which can be done this way :
the developer don't have to create any method called "User" where it will usualy operate with the user action.
Instead of that developer can create same named folder "Web" as the main class and create "User" class inside the folder with method "Login".

now we have : controllers->Web->User.php
and url :

Now the developer want to have a profile for user with option to view,delete or edit profile.
It can be done the same way as above.
All the methods can accept the id of the profile (by ID i mean some number).

example :
Create folder with the subclass name "User" and a new class inside with the name Profile.
so we have : controllers->Web->User->Profile.php
and url :

This feature will sort out :
1. Developer don't have to use too much settings in route to re-route and to have nice and simple url.
2. Keep controllers more organised and to have less code in each controller.
3. Developer can always continue use CodeIgniter the usuall way.
4. When intergrated,Developer don't need to write another file "My_Route.php".

Thanks for reading and I hope this feature will be in CI 4
PS; Don't hesitate to contact me if anyone will need answers.

Theme © iAndrew 2016 - Forum software by © MyBB