hi
I am currently experiencing problems with paths in my included or require_once() files.
Like the paths in those files are relative to where they are located (inside the includes folder) but when I include them outside of that folder say on index.php; the paths no longer work. Because Im using alot of 3rd party javascript files; it will be very hard to find and change each and every path inside the files.
I was wondering if any of the experienced programmers has any advise on how to keep the included files organized and the paths all correct no matter where they are included.... If I place all the files in one folder (root)... that will be too messy no?
Any suggestions would be greatly appreciated!

    I use a config file which oat defines the root & location of different include paths. That way you can refer to absolute filepaths fairly easily.

      SO like in your config file you define different include paths based on where the file doing the including is?
      Like...
      $root_include_path = "includes/";
      $tier1_folder = "../includes/";

      ???

        Nope:

        define(Root, '/my/path/to/root');
        define(Functions, Root.'/include/functions');

          And of course your config file could simply define an include path:

          define('APP_BASE_PATH', '/home/username/public_html/app_name');
          set_include_path(APP_BASE_PATH.'/includes/' . PATH_SEPARATOR . get_include_path());
          

          Then in your application, to include a file in the "includes" directory:

          include "file_name.php";
          

          To include a file in a subdirectory under the includes directory:

          include "subdir/filename.php";
          
            Write a Reply...