core.php 2.9 KB

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