static function init() { // store the current path, and paths of this package (and any included packages) self::$paths = (object) array('base' => getcwd(), 'mini' => $mini = strtolower(substr(__DIR__, 0, 1)) . substr(__DIR__, 1), 'Mustache' => $mini . DIRECTORY_SEPARATOR . "Mustache"); if (substr(self::$paths->base, -4) === __NAMESPACE__) { self::$paths->base = substr(self::$paths->base, 0, -5); } // mini/index.php should be included, not called directly, so just show a welcome page if (ucfirst(realpath(@$_SERVER['SCRIPT_FILENAME'])) === __DIR__ . DIRECTORY_SEPARATOR . "index.php") { self::show_welcome(); } // start capturing output, and set autoload, errorhandler, and shutdown functions $class = get_called_class(); ob_start("{$class}::handle_output"); spl_autoload_register("{$class}::autoload"); set_error_handler("mini\\ErrorHandler::handle"); error_reporting(E_ALL); register_shutdown_function("{$class}::shutdown"); // temporary cache for classes and templates self::$classes = self::make(array('__get' => function ($ob, $class) { return $ob->{$class} = Mini::make(); })); self::$config = self::make(self::load_config($class)); self::init_templates(); self::log("started in " . self::$paths->base . " (mini in " . self::$paths->mini . ")"); }