Access Application Directory in CodeIgniter in Live Environment

Whenever I have to develop a software application in codeigniter first of all I will develop that in my localhost environment. In codeigniter there are different standards for localhost environment and live server environment. Such as the naming conventions of models and controllers. Also directory routing is a major problem between synchronization of localhost and live environment.

In the previous article I have discussed how we can setup directory routing of codeigniter localhost environment and now in this part we are going to discuss how we can do the same thing for the live server.

I will not start explaining again and again which I have already explain in my previous tutorial which you can view here.

The simple is that codeigniter have their own specific directory path keywords which represent specific directories such as APPPATH, which we will use to get the path of application folder within codeigniter directory structure.

You can learn more about path from here.

Suppose that you have structure of directory as application/assets/js/file.jsĀ then you will write code like below.

Whatever the structure you have within the application folder you can access that with the APPPATH keyword and include any kind of file and access that by the above syntax.