Jump to content

Setting up PHP paths to files/directories


kade119

Recommended Posts

What is the best way to link to my js, css, php include files?

 

I found someone structure their site like this .. any advice?

 

<?php

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

/**
* Set include path
*/
ini_set("include_path",
        "$_PATHS[includes]:$_PATHS[pear]:$_PATHS[templates]");

?> 

There are various different methods to creating your 'environment' (for the lack of a better word). The method you have described will work fine, however you will need to watch out for naming collisions. By asking whether your method is good practise, as opposed to just coding and hoping shows that you are on the right track. Keep asking questions and you'll be fine!

Zend uses:

 

define('APPLICATION_PATH', dirname(__FILE__));

$app = new Zend_Application(APPLICATION_ENV, 'path/to/config.ini');
$app->bootstrap('FrontController')->run();

 

The constant APPLICATION_PATH is used/resolved within the config.ini like so:

 

resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.