Organizing Your Controllers into Sub-folders in CI

Why I Copy other People’s Writings

If you are building a large application you might find it convenient to organize your controllers into sub-folders. CodeIgniter permits you to do this.

Simply create folders within your application/controllers directory and place your controller classes within them.

Note:
When using this feature the first segment of your URI must specify the folder. For example, lets say you have a controller located here:

application/controllers/products/shoes.php

To call the above controller your URI will look something like this:

example.com/index.php/products/shoes/show/123

Each of your sub-folders may contain a default controller which will be called if the URL contains only the sub-folder. Simply name your default controller as specified in your application/config/routes.php file

CodeIgniter also permits you to remap your URIs using its URI Routing feature.

Advertisements

About samehramzylabib

See About on https://samehramzylabib.wordpress.com
This entry was posted in CodeIgniter. Bookmark the permalink.

Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s