constants.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. define('BLADE_EXT', '.blade.php');
  3. define('CRLF', chr(13).chr(10));
  4. define('EXT', '.php');
  5. /**
  6. * Define a function that registers an array of constants if they
  7. * haven't already been registered. This allows the constants to
  8. * be changed from their default values when unit testing.
  9. */
  10. function constants($constants)
  11. {
  12. foreach ($constants as $key => $value)
  13. {
  14. if ( ! defined($key)) define($key, $value);
  15. }
  16. }
  17. /**
  18. * Register the core framework paths. All other paths are built on
  19. * top of these core paths. All of these paths are changable by
  20. * the developer in the front controller.
  21. */
  22. $constants = array(
  23. 'APP_PATH' => realpath($application).'/',
  24. 'BASE_PATH' => realpath("$laravel/..").'/',
  25. 'PACKAGE_PATH' => realpath($packages).'/',
  26. 'PUBLIC_PATH' => realpath($public).'/',
  27. 'STORAGE_PATH' => realpath($storage).'/',
  28. 'SYS_PATH' => realpath($laravel).'/',
  29. );
  30. constants($constants);
  31. /**
  32. * Register all of the other framework paths. All of these paths
  33. * are built on top of the core paths above. We still allow the
  34. * developer to override these for easy unit testing.
  35. */
  36. $constants = array(
  37. 'CACHE_PATH' => STORAGE_PATH.'cache/',
  38. 'CONFIG_PATH' => APP_PATH.'config/',
  39. 'CONTROLLER_PATH' => APP_PATH.'controllers/',
  40. 'DATABASE_PATH' => STORAGE_PATH.'database/',
  41. 'LANG_PATH' => APP_PATH.'language/',
  42. 'LIBRARY_PATH' => APP_PATH.'libraries/',
  43. 'MODEL_PATH' => APP_PATH.'models/',
  44. 'ROUTE_PATH' => APP_PATH.'routes/',
  45. 'SESSION_PATH' => STORAGE_PATH.'sessions/',
  46. 'SYS_CONFIG_PATH' => SYS_PATH.'config/',
  47. 'SYS_VIEW_PATH' => SYS_PATH.'views/',
  48. 'VIEW_PATH' => APP_PATH.'views/',
  49. );
  50. constants($constants);
  51. /**
  52. * Set the Laravel environment configuration path constant.
  53. * The environment is controlled by setting an environment
  54. * variable on the server running Laravel.
  55. */
  56. $environment = (isset($_SERVER['LARAVEL_ENV'])) ? $_SERVER['LARAVEL_ENV'] : '';
  57. constants(array('ENV_CONFIG_PATH' => $environment));
  58. unset($constants, $environment);