paths.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. /**
  3. * Laravel - A PHP Framework For Web Artisans
  4. *
  5. * @package Laravel
  6. * @version 3.0.4
  7. * @author Taylor Otwell <taylorotwell@gmail.com>
  8. * @link http://laravel.com
  9. */
  10. // --------------------------------------------------------------
  11. // Initialize the web variable if it doesn't exist.
  12. // --------------------------------------------------------------
  13. if ( ! isset($web)) $web = false;
  14. // --------------------------------------------------------------
  15. // Define the directory separator for the environment.
  16. // --------------------------------------------------------------
  17. if ( ! defined('DS'))
  18. {
  19. define('DS', DIRECTORY_SEPARATOR);
  20. }
  21. // --------------------------------------------------------------
  22. // Define the path to the base directory.
  23. // --------------------------------------------------------------
  24. $GLOBALS['laravel_paths']['base'] = __DIR__.DS;
  25. // --------------------------------------------------------------
  26. // The path to the application directory.
  27. // --------------------------------------------------------------
  28. $paths['app'] = 'application';
  29. // --------------------------------------------------------------
  30. // The path to the Laravel directory.
  31. // --------------------------------------------------------------
  32. $paths['sys'] = 'laravel';
  33. // --------------------------------------------------------------
  34. // The path to the bundles directory.
  35. // --------------------------------------------------------------
  36. $paths['bundle'] = 'bundles';
  37. // --------------------------------------------------------------
  38. // The path to the storage directory.
  39. // --------------------------------------------------------------
  40. $paths['storage'] = 'storage';
  41. // --------------------------------------------------------------
  42. // The path to the public directory.
  43. // --------------------------------------------------------------
  44. if ($web)
  45. {
  46. $GLOBALS['laravel_paths']['public'] = realpath('').DS;
  47. }
  48. else
  49. {
  50. $paths['public'] = 'public';
  51. }
  52. // --------------------------------------------------------------
  53. // Define each constant if it hasn't been defined.
  54. // --------------------------------------------------------------
  55. foreach ($paths as $name => $path)
  56. {
  57. if ($web) $path = "../{$path}";
  58. if ( ! isset($GLOBALS['laravel_paths'][$name]))
  59. {
  60. $GLOBALS['laravel_paths'][$name] = realpath($path).DS;
  61. }
  62. }
  63. /**
  64. * A global path helper function.
  65. *
  66. * <code>
  67. * $storage = path('storage');
  68. * </code>
  69. *
  70. * @param string $path
  71. * @return string
  72. */
  73. function path($path)
  74. {
  75. return $GLOBALS['laravel_paths'][$path];
  76. }
  77. /**
  78. * A global path setter function.
  79. *
  80. * @param string $path
  81. * @param string $value
  82. * @return void
  83. */
  84. function set_path($path, $value)
  85. {
  86. $GLOBALS['laravel_paths'][$path] = $value;
  87. }