paths.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. /**
  3. * Laravel - A PHP Framework For Web Artisans
  4. *
  5. * @package Laravel
  6. * @version 3.1.7
  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. // Change to the current directory if not from the web.
  16. // --------------------------------------------------------------
  17. if ( ! $web)
  18. {
  19. chdir(__DIR__);
  20. }
  21. // --------------------------------------------------------------
  22. // Define the directory separator for the environment.
  23. // --------------------------------------------------------------
  24. if ( ! defined('DS'))
  25. {
  26. define('DS', DIRECTORY_SEPARATOR);
  27. }
  28. // --------------------------------------------------------------
  29. // Define the path to the base directory.
  30. // --------------------------------------------------------------
  31. $GLOBALS['laravel_paths']['base'] = __DIR__.DS;
  32. // --------------------------------------------------------------
  33. // The path to the application directory.
  34. // --------------------------------------------------------------
  35. $paths['app'] = 'application';
  36. // --------------------------------------------------------------
  37. // The path to the Laravel directory.
  38. // --------------------------------------------------------------
  39. $paths['sys'] = 'laravel';
  40. // --------------------------------------------------------------
  41. // The path to the bundles directory.
  42. // --------------------------------------------------------------
  43. $paths['bundle'] = 'bundles';
  44. // --------------------------------------------------------------
  45. // The path to the storage directory.
  46. // --------------------------------------------------------------
  47. $paths['storage'] = 'storage';
  48. // --------------------------------------------------------------
  49. // The path to the public directory.
  50. // --------------------------------------------------------------
  51. if ($web)
  52. {
  53. $GLOBALS['laravel_paths']['public'] = realpath('').DS;
  54. }
  55. else
  56. {
  57. $paths['public'] = 'public';
  58. }
  59. // --------------------------------------------------------------
  60. // Define each constant if it hasn't been defined.
  61. // --------------------------------------------------------------
  62. foreach ($paths as $name => $path)
  63. {
  64. if ($web) $path = "../{$path}";
  65. if ( ! isset($GLOBALS['laravel_paths'][$name]))
  66. {
  67. $GLOBALS['laravel_paths'][$name] = realpath($path).DS;
  68. }
  69. }
  70. /**
  71. * A global path helper function.
  72. *
  73. * <code>
  74. * $storage = path('storage');
  75. * </code>
  76. *
  77. * @param string $path
  78. * @return string
  79. */
  80. function path($path)
  81. {
  82. return $GLOBALS['laravel_paths'][$path];
  83. }
  84. /**
  85. * A global path setter function.
  86. *
  87. * @param string $path
  88. * @param string $value
  89. * @return void
  90. */
  91. function set_path($path, $value)
  92. {
  93. $GLOBALS['laravel_paths'][$path] = $value;
  94. }