core.php 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php namespace Laravel;
  2. // --------------------------------------------------------------
  3. // Define the PHP file extensions.
  4. // --------------------------------------------------------------
  5. define('EXT', '.php');
  6. define('BLADE_EXT', '.blade.php');
  7. // --------------------------------------------------------------
  8. // Define the core framework paths.
  9. // --------------------------------------------------------------
  10. define('APP_PATH', realpath($application).'/');
  11. define('BASE_PATH', realpath(str_replace('laravel', '', $laravel)).'/');
  12. define('PACKAGE_PATH', realpath($packages).'/');
  13. define('PUBLIC_PATH', realpath($public).'/');
  14. define('STORAGE_PATH', realpath($storage).'/');
  15. define('SYS_PATH', realpath($laravel).'/');
  16. unset($laravel, $application, $config, $packages, $public, $storage);
  17. // --------------------------------------------------------------
  18. // Define various other framework paths.
  19. // --------------------------------------------------------------
  20. define('CACHE_PATH', STORAGE_PATH.'cache/');
  21. define('CONFIG_PATH', APP_PATH.'config/');
  22. define('CONTROLLER_PATH', APP_PATH.'controllers/');
  23. define('DATABASE_PATH', STORAGE_PATH.'database/');
  24. define('LANG_PATH', APP_PATH.'language/');
  25. define('ROUTE_PATH', APP_PATH.'routes/');
  26. define('SESSION_PATH', STORAGE_PATH.'sessions/');
  27. define('SYS_CONFIG_PATH', SYS_PATH.'config/');
  28. define('SYS_LANG_PATH', SYS_PATH.'language/');
  29. define('VIEW_PATH', APP_PATH.'views/');
  30. // --------------------------------------------------------------
  31. // Load the configuration manager and its dependencies.
  32. // --------------------------------------------------------------
  33. require SYS_PATH.'facades'.EXT;
  34. require SYS_PATH.'config'.EXT;
  35. require SYS_PATH.'loader'.EXT;
  36. require SYS_PATH.'arr'.EXT;
  37. // --------------------------------------------------------------
  38. // Determine the application environment.
  39. // --------------------------------------------------------------
  40. $environment = (isset($_SERVER['LARAVEL_ENV'])) ? $_SERVER['LARAVEL_ENV'] : null;
  41. // --------------------------------------------------------------
  42. // Register the configuration file paths.
  43. // --------------------------------------------------------------
  44. $config = array(SYS_CONFIG_PATH, CONFIG_PATH);
  45. if ( ! is_null($environment)) $config[] = CONFIG_PATH.$environment.'/';
  46. Config::paths($config);
  47. // --------------------------------------------------------------
  48. // Set a few core configuration options.
  49. // --------------------------------------------------------------
  50. Config::set('view.path', VIEW_PATH);
  51. // --------------------------------------------------------------
  52. // Bootstrap the IoC container.
  53. // --------------------------------------------------------------
  54. require SYS_PATH.'container'.EXT;
  55. $container = new Container(Config::get('container'));
  56. IoC::$container = $container;
  57. // --------------------------------------------------------------
  58. // Register the auto-loader on the auto-loader stack.
  59. // --------------------------------------------------------------
  60. spl_autoload_register(array('Laravel\\Loader', 'load'));
  61. Loader::$paths = array(BASE_PATH, APP_PATH.'models/', APP_PATH);
  62. Loader::$aliases = Config::get('aliases');
  63. // --------------------------------------------------------------
  64. // Define some convenient global functions.
  65. // --------------------------------------------------------------
  66. function e($value)
  67. {
  68. return HTML::entities($value);
  69. }
  70. function __($key, $replacements = array(), $language = null)
  71. {
  72. return Lang::line($key, $replacements, $language);
  73. }