As you already notice, the “/application/” folder are resides in the “/system/” folder. For some security reason (because in “/system/” folder contains all our back-end configuration and etc), and some recommendation from CI users, I suggest that you copy your “/application/” folder outside the “/system/” folder.
But, this is not the main point of my Ease of Use entry. The main item that i wanted to highlight to you are about your “/CSS/” and “/images/” folder. There are some minor discussion going in our room, discussing where should we put our 2 “most important” folder and files (in that folder).
At first, we decided to put it in the “/Views/” folder which are in the “/application/” folder.
The path of the folder are as such:
http://localhost/site/application/views/css/style.css http://localhost/site/application/views/images/some_img.png
But, after googling around, and found some tutorial giving some nice lecturers, I decided to put both folders at the root folder. To put it simple, at the same level of your “/application/” and “/system/” folder.
Why I decide to put both folder in such manner?
The reason is, it is easier during the coding process, for us to fetch the, in example, the stylesheet (style.css). Instead of you need to access it through the path folder “/application/views/css/style.css“, you can just specify the path as “/css/style.css“.
1 2 3 4 5 6 7 | //So, instead of using $this->file(BASEPATH.'application/views/css/style.css'); //you can just use $this->file(BASEPATH.'css/style.css'); //when you want to call for the files. |
Or, if you wanted to call an image in your code, with the help of CI’s HTML_Helper , you can call the image using
1 | <?php echo img(array('src' => 'images/logo.png', 'class' => 'some_class')); ?> |
instead of
1 | <?php echo img(array('src' =>'application/views/images/logo.png', 'class' => 'some_class')); ?> |
At first, you don’t see it as a problem, just a little different in the folder’s path. But, as your code grew larger, your code will look messy and full of those paths. I don’t know about you, but i’ll get dizzy when it comes to debug something that is not well organized and messy. Pheww! Such a hassle to identify what i really need to take care of.
Also, if you are a web designer (like me), of course, once in a while, you will go through other sites to peek (or copy) their stylesheet (For God Sake, I do!
). So, you don’t want them to know the path of your folders resides(For some security reason, I guess).
Tags: codeigniter, folder, organizing, php