On Feb 22, 7:27 am, "Rhett Waldock" <[EMAIL PROTECTED]> wrote:
> Hello Everyone,
>
> Another thread here made me want to raise a question of best practices when
> defining directory paths - it really applies both in Cake and in general.
>
> I notice that the Cake convention when defining paths is to create a
> concatenated string for the path using the "DS" constant for each directory
> separator in the path. An example, selectively copied from a post in
> another thread:
>
> if (!defined('ROOT')) {
> define('ROOT', 'C:'.DS.'wamp'.DS.'apps');}
>
> if (!defined('CAKE_CORE_INCLUDE_PATH')) {
> define('CAKE_CORE_INCLUDE_PATH', 'C:'.DS.'wamp'.DS.'cake' );
>
> }
>
> I completely understand why it's important to use the DS constant for
> "self-discovery" paths that are generated on-the-fly on many platforms (like
> the Cake core). However, when defining these absolute paths, which
> obviously do not cross platforms anyways, what is the benefit of this
> convention?
You can move the entire folder structure around (to a subdomain for
example) and back again and it still works.
>
> Using continuous strings, the values are much more readable and also easier
> to change:
>
> if (!defined('ROOT')) {
> define('ROOT', 'C:\wamp\apps');}
>
> if (!defined('CAKE_CORE_INCLUDE_PATH')) {
> define('CAKE_CORE_INCLUDE_PATH', 'C:\wamp\cake' );
>
> }
>
> What am I missing?
>
> Rhett
You don't need to define those constants unless you have some kind of
problem or are changing the folder structure from the default. If you /
do/ define them like that your install is nolonger portable (or is
only portable to another system with the same OS and exactly the same
folder structure). Does your development/test machine/environment have
the same OS and folder structure as the live site?
Cheers,
AD
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---