public static function path($view) { $view = str_replace(".", "/", $view); $file = App::getAppRoot() . "/views/{$view}.php"; if (!file_exists($file)) { throw new \RuntimeException("View Not Found: [{$file}]"); } return $file; }
/** * return stdClass by default */ public static function get($name, $array = false) { $file = App::getAppRoot() . "/config/{$name}.php"; if (!file_exists($file)) { throw new \RuntimeException("Config Not Found: [{$name}]"); } $config = (include $file); if (!is_array($config)) { throw new \RuntimeException("Invalid Config: [{$name}]"); } return $array ? $config : (object) $config; }
<?php use Caravel\Console\App; use Caravel\Routing\ClassLoader; use Caravel\Config\Config; /* |-------------------------------------------------------------------------- | Register The Class Loader |-------------------------------------------------------------------------- | | You may use the class loader to load your controllers and models. | This is useful for keeping all of your classes in the "global" namespace. | */ ClassLoader::addPaths(array(App::getAppRoot() . "/controllers", App::getAppRoot() . "/models"))->register(); /* |-------------------------------------------------------------------------- | Class Aliases |-------------------------------------------------------------------------- | | This array of class aliases will be registered when this application | is started. However, feel free to register as many as you wish as | the aliases are "lazy" loaded so they don't hinder performance. | */ App::alias(Config::get("app")->aliases); /* |-------------------------------------------------------------------------- | Application Error Logger |-------------------------------------------------------------------------- |