PHP Application Structure

[ via Laughing Meme ] PHPGuru describes his method for setting up the folders of a new PHP application.

The bonus, using the __FILE__ idiom to set up portable paths. He has this in his config.php:

<?php

$_PATHS["base"]      = dirname(dirname(__FILE__)) . "/";

$_PATHS["includes"]  = $_PATHS["base"] . "includes/";

$_PATHS["templates"] = $_PATHS["base"] . "templates/";

$_PATHS["pear"]      = $_PATHS["base"] . "pear/";

$_PATHS["logs"]      = $_PATHS["base"] . "logs/";

/**

* Set include path

*/

ini_set("include_path",

        "$_PATHS[includes]:$_PATHS[pear]:$_PATHS[templates]");

?>

Your app now can sort itself out wherever you drop it. Cool, huh?

More like this: .