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]");

?> 

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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"

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.