示例#1
0
文件: halfmoon.php 项目: jcs/halfmoon
    require_once HALFMOON_ROOT . "/config/boot.php";
}
/* autoload controllers and helpers as needed */
function halfmoon_autoload($class_name)
{
    if (preg_match("/^([A-Za-z0-9_]+)(Controller|Helper)\$/", $class_name, $m)) {
        $file = HALFMOON_ROOT . "/";
        /* Controller -> controllers/ */
        $file .= strtolower($m[2]) . "s/";
        /* CamelCase -> camel_case_controller.php */
        $words = preg_split('/(?<=\\w)(?=[A-Z])/', $m[1]);
        $file .= strtolower(join("_", $words)) . "_" . strtolower($m[2]) . ".php";
        if (file_exists($file)) {
            require_once $file;
        }
    }
}
spl_autoload_register("halfmoon_autoload", false, false);
if (defined("PHP_ACTIVERECORD_ROOT")) {
    HalfMoon\Config::initialize_activerecord();
}
/* bring in any post-framework but pre-route code */
if (file_exists($f = HALFMOON_ROOT . "/config/application.php")) {
    require_once $f;
}
/* bring in the route table and route our request */
if (file_exists(HALFMOON_ROOT . "/config/routes.php")) {
    HalfMoon\Router::initialize(function ($router) {
        require_once HALFMOON_ROOT . "/config/routes.php";
    });
}