您好,以下是关于是否在PHP应用程序中使用引导程序的最佳实践。我发现有两种方法可以引导我的PHP应用程序。需要一些建议哪种方法更好。
第一种方法:
为文件夹结构定义一个常量
$controllerPath = 'controller';
define('CONTROLLER', str_replace('\\', '/', realpath($controllerPath)).'/');
//usage
require_once CONTROLLER . 'somecontroller.php';
第二步
使用ini_set将包含路径设置为应用程序根目录。
$rootPath = $_SERVER['DOCUMENT_ROOT'];
$includePath = ini_get('include_path');
ini_set('include_path', '.'.PATH_SEPARATOR.$rootPath.PATH_SEPARATOR.$includePath);
//usage
require_once 'controller/somecontroller.php';
请告诉我哪种方式更好。
对于高负载应用程序,哪种方法最好?