• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
where do you put your path definitions - define or an array?

#1
[eluser]Brian Dickson[/eluser]
In procedural PHP which I have mainly used up till recently, I like to define various paths to common directories, so if I have to move or rename a folder, I only have to reflect that change in one place, so the whole app doesn't brake. I used to define these paths in an array which was located in a config file.

What do people use in CI to define and store their config paths? (config class/define/data array from db?)

#2
[eluser]n0xie[/eluser]
What paths are you talking about? Most paths we use are either relative to the webserver root, or relative to the APPATH, both which are already defined.

#3
[eluser]Brian Dickson[/eluser]
I used to specify paths to directories for example:
Code:
$path['www'] = $depth;
$path['home'] = $depth . 'index.html';
$path['views'] = $depth . '../system/views/';
$path['menus'] = $depth . '../system/menus/';
$path['classes'] = $depth . '../system/classes/';
$path['functions'] = $depth . '../system/functions/';
$path['errors'] = $depth . '../system/errors/';
$path['content'] = $depth . 'content/';
$path['js'] = $depth . 'js/';

but on further thought after your post, I can see I'm still thinking procedural and that CI negates the need for most of this, the path to classes is taken care of by Libraries and a functions directory is taken care of by CI helpers directory.

So maybe using CI, I no longer need to define these?

#4
[eluser]n0xie[/eluser]
Hence my question Smile

Like you said so yourself, classes are usually 'converted' to CI libraries, and functions are usually 'converted' to helpers (procedural) or libraries (classes). The views are already defined for you, and since menu's are just a specific type of view they don't need to be specified. Errors are also already defined for you.

Basically the only 2 paths you should be using are the webserver root and the APPATH, and CI already defines them for you. This is part of the automagic that makes CI a great framework to work with, using convention over configuration. You will notice that after you worked on a few projects with CI, that you always 'know' where certain files are since every CI install is exactly the same, which saves you a lot of time when debugging.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.