Hola,
Puedes utilizar (espero) la directiva de configuración
"include_path" (con la función
ini_set()). Sin embargo, personalmente, suelo usar rutas absolutas. Ojo. No estoy diciendo que "include_path" no funcione: quizás es que me he acostumbrado a hacerlo como digo y nada más. Empero, el hecho de que se cambiaran los directorios en un momento dado no debería significar un problema. Me explico. Tu aplicación definiría un directorio "raíz", partiendo de la situación de un determinado "script" (que estaría en el directorio raíz) y a partir de ahí se construirían las rutas de todos los demás directorios. Entonces, si se cambia algún directorio "fuera del raíz", no pasaría nada, puesto que el directorio raíz de tu aplicación, determinado por la posición de un cierto "script", no cambiaría.
Es un poco "largo", pero, te voy a copiar abajo el archivo "gb-init.php" de Gesbit. Observa que dicho archivo se encuentra en el directorio "raíz" de Gesbit, y que, por tanto, esté donde esté situado dicho directorio, siempre será el directorio raíz para Gesbit, que es lo que importa, por decirlo así. Fíjate en el siguiente código y si tienes alguna duda pregunta.
Código PHP:
<?php
/*
Copyrights (C) 2007-2008 David Esperalta <davidesperalta@gmail.com>
This file is part of Gesbit (Gestor de Bitácoras in spanish)
Gesbit is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation, either version 3 of the License,
or (at your option) any later version.
Gesbit is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
License for more details.
You should have received a copy of the GNU General Public License
along with Gesbit. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* Hi. You can see the first require script to the entrypoints of
* Gesbit. This script define some main Gesbit constants, and then
* require a script that initialize the Gesbit system.
*
* This script is required in all Gesbit entrypoints scripts, because
* initialize the Gesbit system, and make available all the Gesbit
* global variables. Also assert the Gesbit requisites or die.
*
* @package initialization
* @subpackage entrypoints
* @author David Esperalta <davidesperalta@gmail.com>
* @license http://www.gnu.org/licenses/ GNU General Public License
*
*/
/**
* Define the root directory path. All other Gesbit related dirs
* are relative to this directory. Note that we end the directory
* with the appropiate separator: this is a norm in all constants.
*/
define('GB_ROOT_DIR_PATH',
dirname(__FILE__).DIRECTORY_SEPARATOR
);
/**
* Define the root directory url. All other Gesbit related urls
* are relative to this directory url. Note the diference with
* the directory path constant: this is a url, not a system path.
*/
define('GB_ROOT_DIR_URL',str_replace(
'index.php','',$_SERVER['SCRIPT_NAME']
));
/**
* Define the directory name for Gesbit admin files.
* This is a subdirectory of {@link GB_ROOT_DIR_PATH}
*/
define('GB_ADMIN_DIR_NAME', 'gb-admin');
/**
* Define the directory name for Gesbit content files.
* This is a subdirectory of {@link GB_ROOT_DIR_PATH}
*/
define('GB_CONTENT_DIR_NAME', 'gb-content');
/**
* Define the directory name for Gesbit auxiliar files.
* This is a subdirectory of {@link GB_ROOT_DIR_PATH}
*/
define('GB_AUXILIAR_DIR_NAME', 'gb-auxiliar');
/**
* Define the directory name for Gesbit error scripts.
* This is a subdirectory of the {@link GB_AUXILIAR_DIR}
*/
define('GB_ERRORS_DIR_NAME', 'errors');
/**
* Define the directory name for Gesbit locale files.
* This is a subdirectory of the {@link GB_AUXILIAR_DIR}
*/
define('GB_LOCALE_DIR_NAME', 'locale');
/**
* Define the directory name for Gesbit PHP classes.
* This is a subdirectory of the {@link GB_AUXILIAR_DIR}
*/
define('GB_CLASSES_DIR_NAME', 'classes');
/**
* Define the directory name for Gesbit requires scripts.
* This is a subdirectory of the {@link GB_AUXILIAR_DIR}
*/
define('GB_REQUIRES_DIR_NAME', 'requires');
/**
* Define the directory name for Gesbit CSS stylesheets.
* This is a subdirectory of the {@link GB_AUXILIAR_DIR}
*/
define('GB_CSS_STYLES_DIR_NAME', 'styles');
/**
* Define the directory name for Gesbit DB install script.
* This is a subdirectory of the {@link GB_AUXILIAR_DIR}
*/
define('GB_DBINSTALL_DIR_NAME', 'dbinstall');
/**
* Define the directory name for KSES PHP library.
* This is a subdirectory of the {@link GB_CLASSES_DIR}
*/
define('GB_KSES_DIR_NAME', 'kses');
/**
* Define the directory name for PHPass PHP library.
* This is a subdirectory of the {@link GB_CLASSES_DIR}
*/
define('GB_PHPASS_DIR_NAME', 'phpass');
/**
* Define the directory name for PHP Snoopy library.
* This is a subdirectory of the {@link GB_CLASSES_DIR}
*/
define('GB_SNOOPY_DIR_NAME', 'snoopy');
/**
* Define the directory name for Incutio XML-RPC library.
* This is a subdirectory of the {@link GB_CLASSES_DIR}
*/
define('GB_IXMLRPC_DIR_NAME', 'ixmlrpc');
/**
* Define the directory name for PHP GetText library.
* This is a subdirectory of the {@link GB_CLASSES_DIR}
*/
define('GB_PHPGETTEXT_DIR_NAME', 'phpgettext');
/**
* Define the directory name for Gesbit themes.
* This is a subdirectory of the {@link GB_CONTENT_DIR}
*/
define('GB_THEMES_DIR_NAME', 'themes');
/**
* Define the directory name for Gesbit default theme.
* This is a subdirectory of the {@link GB_THEMES_DIR}
*/
define('GB_DEFAULT_THEME_DIR_NAME', 'default');
/**
* Define the directory name for Gesbit plugins.
* This is a subdirectory of the {@link GB_CONTENT_DIR}
*/
define('GB_PLUGINS_DIR_NAME', 'plugins');
/**
* Define the directory path for Gesbit admin files.
* This is a subdirectory of {@link GB_ROOT_DIR_PATH}
*/
define('GB_ADMIN_DIR',
GB_ROOT_DIR_PATH . GB_ADMIN_DIR_NAME . DIRECTORY_SEPARATOR
);
/**
* Define the directory path for Gesbit content files.
* This is a subdirectory of {@link GB_ROOT_DIR_PATH}
*/
define('GB_CONTENT_DIR',
GB_ROOT_DIR_PATH . GB_CONTENT_DIR_NAME . DIRECTORY_SEPARATOR
);
/**
* Define the directory path for Gesbit auxiliar files.
* This is a subdirectory of {@link GB_ROOT_DIR_PATH}
*/
define('GB_AUXILIAR_DIR',
GB_ROOT_DIR_PATH . GB_AUXILIAR_DIR_NAME . DIRECTORY_SEPARATOR
);
/**
* Define the directory path for Gesbit themes.
* This is a subdirectory of {@link GB_CONTENT_DIR}
*/
define('GB_THEMES_DIR',
GB_CONTENT_DIR . GB_THEMES_DIR_NAME . DIRECTORY_SEPARATOR
);
/**
* Define the directory path for Gesbit plugins.
* This is a subdirectory of {@link GB_CONTENT_DIR}
*/
define('GB_PLUGINS_DIR',
GB_CONTENT_DIR . GB_PLUGINS_DIR_NAME . DIRECTORY_SEPARATOR
);
/**
* Define the directory path for Gesbit locale files.
* This is a subdirectory of {@link GB_AUXILIAR_DIR}
*/
define('GB_LOCALE_DIR',
GB_AUXILIAR_DIR . GB_LOCALE_DIR_NAME . DIRECTORY_SEPARATOR
);
/**
* Define the directory path for Gesbit require files.
* This is a subdirectory of {@link GB_AUXILIAR_DIR}
*/
define('GB_REQUIRES_DIR',
GB_AUXILIAR_DIR . GB_REQUIRES_DIR_NAME . DIRECTORY_SEPARATOR
);
/**
* Define the directory path for Gesbit CSS stylesheets.
* This is a subdirectory of the {@link GB_AUXILIAR_DIR}
*/
define('GB_CSS_STYLES_DIR',
GB_AUXILIAR_DIR . GB_CSS_STYLES_DIR_NAME . DIRECTORY_SEPARATOR
);
/**
* Define the directory path for Gesbit error scripts.
* This is a subdirectory of the {@link GB_AUXILIAR_DIR}
*/
define('GB_ERRORS_DIR',
GB_AUXILIAR_DIR . GB_ERRORS_DIR_NAME . DIRECTORY_SEPARATOR
);
/**
* Define the directory path for Gesbit default theme.
* This is a subdirectory of the {@link GB_THEMES_DIR}
*/
define('GB_DEFAULT_THEME_DIR',
GB_THEMES_DIR . GB_DEFAULT_THEME_DIR_NAME . DIRECTORY_SEPARATOR
);
/**
* Define the directory path for Gesbit PHP classes.
* This is a subdirectory of the {@link GB_AUXILIAR_DIR}
*/
define('GB_CLASSES_DIR',
GB_AUXILIAR_DIR . GB_CLASSES_DIR_NAME . DIRECTORY_SEPARATOR
);
/**
* Define the directory path for KSES PHP library.
* This is a subdirectory of the {@link GB_CLASSES_DIR}
*/
define('GB_KSES_DIR',
GB_CLASSES_DIR . GB_KSES_DIR_NAME . DIRECTORY_SEPARATOR
);
/**
* Define the directory path for PHPass library.
* This is a subdirectory of the {@link GB_CLASSES_DIR}
*/
define('GB_PHPASS_DIR',
GB_CLASSES_DIR . GB_PHPASS_DIR_NAME . DIRECTORY_SEPARATOR
);
/**
* Define the directory path for PHP GetText library.
* This is a subdirectory of the {@link GB_CLASSES_DIR}
*/
define('GB_PHPGETTEXT_DIR',
GB_CLASSES_DIR . GB_PHPGETTEXT_DIR_NAME . DIRECTORY_SEPARATOR
);
/**
* Define the directory path for Snoopy library.
* This is a subdirectory of the {@link GB_CLASSES_DIR}
*/
define('GB_SNOOPY_DIR',
GB_CLASSES_DIR . GB_SNOOPY_DIR_NAME . DIRECTORY_SEPARATOR
);
/**
* Define the directory path for Incutio XML-RPC library.
* This is a subdirectory of the {@link GB_CLASSES_DIR}
*/
define('GB_IXMLRPC_DIR',
GB_CLASSES_DIR . GB_IXMLRPC_DIR_NAME . DIRECTORY_SEPARATOR
);
/**
* Define the directory path for Gesbit DB install script.
* This is a subdirectory of the {@link GB_AUXILIAR_DIR}
*/
define('GB_DBINSTALL_DIR',
GB_AUXILIAR_DIR . GB_DBINSTALL_DIR_NAME . DIRECTORY_SEPARATOR
);
/**
* Define a hash to use in the Gesbit related cookie names.
*/
define('GB_COOKIE_HASH', 'gb-' . substr(md5(GB_ROOT_DIR_PATH), 5, 5));
/**
* Require to initialize the Gesbit system.
*/
require(GB_REQUIRES_DIR.'gb-mainrequires.php');
?>