core.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php namespace Laravel;
  2. /*
  3. |--------------------------------------------------------------------------
  4. | PHP Display Errors Configuration
  5. |--------------------------------------------------------------------------
  6. |
  7. | Register the constants used by the framework. These are things like file
  8. | extensions and other information that we want to be able to access with
  9. | just a simple constant.
  10. |
  11. */
  12. define('EXT', '.php');
  13. define('CRLF', "\r\n");
  14. define('DEFAULT_BUNDLE', 'application');
  15. define('MB_STRING', (int) function_exists('mb_get_info'));
  16. /*
  17. |--------------------------------------------------------------------------
  18. | Require Core Classes
  19. |--------------------------------------------------------------------------
  20. |
  21. | Here we will just load in the classes that are used for every request
  22. | or are used by the configuration class. It is quicker and simpler to
  23. | just manually load them in instead of using the auto-loader.
  24. |
  25. */
  26. require path('sys').'ioc'.EXT;
  27. require path('sys').'event'.EXT;
  28. require path('sys').'bundle'.EXT;
  29. require path('sys').'config'.EXT;
  30. require path('sys').'helpers'.EXT;
  31. require path('sys').'autoloader'.EXT;
  32. /*
  33. |--------------------------------------------------------------------------
  34. | Register The Framework Auto-Loader
  35. |--------------------------------------------------------------------------
  36. |
  37. | Next we'll register the Autoloader class on the SPL auto-loader stack
  38. | so it can lazy-load our class files as we need them. This class and
  39. | method will be called each time a class is needed but has not been
  40. | defined yet and will load the appropriate file.
  41. |
  42. */
  43. spl_autoload_register(array('Laravel\\Autoloader', 'load'));
  44. /*
  45. |--------------------------------------------------------------------------
  46. | Register The Laravel Namespace
  47. |--------------------------------------------------------------------------
  48. |
  49. | Register the "Laravel" namespace and its directory mapping so the class
  50. | loader can quickly load all of the core classes using PSR-0 style load
  51. | conventions throughout the "laravel" directory since all core classes
  52. | are namespaced into the "Laravel" namespace.
  53. |
  54. */
  55. Autoloader::namespaces(array('Laravel' => path('sys')));
  56. /*
  57. |--------------------------------------------------------------------------
  58. | Set The CLI Options Array
  59. |--------------------------------------------------------------------------
  60. |
  61. | If the current request is from the Artisan command-line interface, we
  62. | will parse the command line arguments and options and set them the
  63. | array of options in the $_SERVER global array for convenience.
  64. |
  65. */
  66. if (defined('STDIN'))
  67. {
  68. $console = CLI\Command::options($_SERVER['argv']);
  69. list($arguments, $options) = $console;
  70. $options = array_change_key_case($options, CASE_UPPER);
  71. $_SERVER['CLI'] = $options;
  72. }
  73. /*
  74. |--------------------------------------------------------------------------
  75. | Set The CLI Laravel Environment
  76. |--------------------------------------------------------------------------
  77. |
  78. | Next we'll set the LARAVEL_ENV variable if the current request is from
  79. | the Artisan command-line interface. Since the environment is often
  80. | specified within an Apache .htaccess file, we need to set it here
  81. | when the request is not coming through Apache.
  82. |
  83. */
  84. if (isset($_SERVER['CLI']['ENV']))
  85. {
  86. $_SERVER['LARAVEL_ENV'] = $_SERVER['CLI']['ENV'];
  87. }
  88. /*
  89. |--------------------------------------------------------------------------
  90. | Register The Laravel Bundles
  91. |--------------------------------------------------------------------------
  92. |
  93. | Finally we will register all of the bundles that have been defined for
  94. | the application. None of them will be started, yet but will be setup
  95. | so that they may be started by the develop at any time.
  96. |
  97. */
  98. $bundles = require path('app').'bundles'.EXT;
  99. foreach ($bundles as $bundle => $config)
  100. {
  101. Bundle::register($bundle, $config);
  102. }