core.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php namespace Laravel;
  2. /**
  3. * Define all of the constants that we will need to use the framework.
  4. * These are things like file extensions, as well as all of the paths
  5. * used by the framework. All of the paths are built on top of the
  6. * basic application, laravel, and public paths.
  7. */
  8. define('EXT', '.php');
  9. define('CRLF', "\r\n");
  10. define('BLADE_EXT', '.blade.php');
  11. define('DEFAULT_BUNDLE', 'application');
  12. define('MB_STRING', (int) function_exists('mb_get_info'));
  13. /**
  14. * Require all of the classes that can't be loaded by the auto-loader.
  15. * These are typically classes that the auto-loader relies upon to
  16. * load classes, such as the array and configuration classes.
  17. */
  18. require path('sys').'event'.EXT;
  19. require path('sys').'bundle'.EXT;
  20. require path('sys').'config'.EXT;
  21. require path('sys').'helpers'.EXT;
  22. require path('sys').'autoloader'.EXT;
  23. /**
  24. * Register the Autoloader's "load" method on the auto-loader stack.
  25. * This method provides the lazy-loading of all class files, as well
  26. * as any PSR-0 compliant libraries used by the application.
  27. */
  28. spl_autoload_register(array('Laravel\\Autoloader', 'load'));
  29. /**
  30. * Register the Laravel namespace so that the auto-loader loads it
  31. * according to the PSR-0 naming conventions. This should provide
  32. * fast resolution of all core classes.
  33. */
  34. Autoloader::namespaces(array('Laravel' => path('sys')));
  35. /**
  36. * Set the CLI options on the $_SERVER global array so we can easily
  37. * retrieve them from the various parts of the CLI code. We can use
  38. * the Request class to access them conveniently.
  39. */
  40. if (defined('STDIN'))
  41. {
  42. $console = CLI\Command::options($_SERVER['argv']);
  43. list($arguments, $options) = $console;
  44. $options = array_change_key_case($options, CASE_UPPER);
  45. $_SERVER['CLI'] = $options;
  46. }
  47. /**
  48. * The Laravel environment may be specified on the CLI using the env
  49. * option, allowing the developer to easily use local configuration
  50. * files from the CLI since the environment is usually controlled
  51. * by server environmenet variables.
  52. */
  53. if (isset($_SERVER['CLI']['ENV']))
  54. {
  55. $_SERVER['LARAVEL_ENV'] = $_SERVER['CLI']['ENV'];
  56. }
  57. /**
  58. * Register all of the core class aliases. These aliases provide a
  59. * convenient way of working with the Laravel core classes without
  60. * having to worry about the namespacing. The developer is also
  61. * free to remove aliases when they extend core classes.
  62. */
  63. Autoloader::$aliases = Config::get('application.aliases');
  64. /**
  65. * Register the default timezone for the application. This will
  66. * be the default timezone used by all date functions through
  67. * throughout the entire application.
  68. */
  69. $timezone = Config::get('application.timezone');
  70. date_default_timezone_set($timezone);
  71. /**
  72. * Finally we'll grab all of the bundles and register them
  73. * with the bundle class. All of the bundles are stored in
  74. * an array within the application directory.
  75. */
  76. $bundles = require path('app').'bundles'.EXT;
  77. foreach ($bundles as $bundle => $config)
  78. {
  79. Bundle::register($bundle, $config);
  80. }