defines.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. /**
  3. * @package Grav\Core
  4. *
  5. * @copyright Copyright (c) 2015 - 2022 Trilby Media, LLC. All rights reserved.
  6. * @license MIT License; see LICENSE file for details.
  7. */
  8. // Some standard defines
  9. define('GRAV', true);
  10. define('GRAV_VERSION', '1.7.37.1');
  11. define('GRAV_SCHEMA', '1.7.0_2020-11-20_1');
  12. define('GRAV_TESTING', false);
  13. // PHP minimum requirement
  14. if (!defined('GRAV_PHP_MIN')) {
  15. define('GRAV_PHP_MIN', '7.3.6');
  16. }
  17. // Directory separator
  18. if (!defined('DS')) {
  19. define('DS', '/');
  20. }
  21. // Absolute path to Grav root. This is where Grav is installed into.
  22. if (!defined('GRAV_ROOT')) {
  23. $path = rtrim(str_replace(DIRECTORY_SEPARATOR, DS, getenv('GRAV_ROOT') ?: getcwd()), DS);
  24. define('GRAV_ROOT', $path);
  25. }
  26. // Absolute path to Grav webroot. This is the path where your site is located in.
  27. if (!defined('GRAV_WEBROOT')) {
  28. $path = rtrim(getenv('GRAV_WEBROOT') ?: GRAV_ROOT, DS);
  29. define('GRAV_WEBROOT', $path);
  30. }
  31. // Relative path to user folder. This path needs to be located under GRAV_WEBROOT.
  32. if (!defined('GRAV_USER_PATH')) {
  33. $path = rtrim(getenv('GRAV_USER_PATH') ?: 'user', DS);
  34. define('GRAV_USER_PATH', $path);
  35. }
  36. // Absolute or relative path to system folder. Defaults to GRAV_ROOT/system
  37. // If system folder is outside of webroot, see https://github.com/getgrav/grav/issues/3297#issuecomment-810294972
  38. if (!defined('GRAV_SYSTEM_PATH')) {
  39. $path = rtrim(getenv('GRAV_SYSTEM_PATH') ?: 'system', DS);
  40. define('GRAV_SYSTEM_PATH', $path);
  41. }
  42. // Absolute or relative path to cache folder. Defaults to GRAV_ROOT/cache
  43. if (!defined('GRAV_CACHE_PATH')) {
  44. $path = rtrim(getenv('GRAV_CACHE_PATH') ?: 'cache', DS);
  45. define('GRAV_CACHE_PATH', $path);
  46. }
  47. // Absolute or relative path to logs folder. Defaults to GRAV_ROOT/logs
  48. if (!defined('GRAV_LOG_PATH')) {
  49. $path = rtrim(getenv('GRAV_LOG_PATH') ?: 'logs', DS);
  50. define('GRAV_LOG_PATH', $path);
  51. }
  52. // Absolute or relative path to tmp folder. Defaults to GRAV_ROOT/tmp
  53. if (!defined('GRAV_TMP_PATH')) {
  54. $path = rtrim(getenv('GRAV_TMP_PATH') ?: 'tmp', DS);
  55. define('GRAV_TMP_PATH', $path);
  56. }
  57. // Absolute or relative path to backup folder. Defaults to GRAV_ROOT/backup
  58. if (!defined('GRAV_BACKUP_PATH')) {
  59. $path = rtrim(getenv('GRAV_BACKUP_PATH') ?: 'backup', DS);
  60. define('GRAV_BACKUP_PATH', $path);
  61. }
  62. unset($path);
  63. // INTERNAL: Do not use!
  64. define('USER_DIR', GRAV_WEBROOT . '/' . GRAV_USER_PATH . '/');
  65. define('CACHE_DIR', (!preg_match('`^(/|[a-z]:[\\\/])`ui', GRAV_CACHE_PATH) ? GRAV_ROOT . '/' : '') . GRAV_CACHE_PATH . '/');
  66. // DEPRECATED: Do not use!
  67. define('CACHE_PATH', GRAV_CACHE_PATH . DS);
  68. define('USER_PATH', GRAV_USER_PATH . DS);
  69. define('ROOT_DIR', GRAV_ROOT . DS);
  70. define('ASSETS_DIR', GRAV_WEBROOT . '/assets/');
  71. define('IMAGES_DIR', GRAV_WEBROOT . '/images/');
  72. define('ACCOUNTS_DIR', USER_DIR . 'accounts/');
  73. define('PAGES_DIR', USER_DIR . 'pages/');
  74. define('DATA_DIR', USER_DIR . 'data/');
  75. define('PLUGINS_DIR', USER_DIR . 'plugins/');
  76. define('THEMES_DIR', USER_DIR . 'themes/');
  77. define('SYSTEM_DIR', (!preg_match('`^(/|[a-z]:[\\\/])`ui', GRAV_SYSTEM_PATH) ? GRAV_ROOT . '/' : '') . GRAV_SYSTEM_PATH . '/');
  78. define('LIB_DIR', SYSTEM_DIR . 'src/');
  79. define('VENDOR_DIR', GRAV_ROOT . '/vendor/');
  80. define('LOG_DIR', (!preg_match('`^(/|[a-z]:[\\\/])`ui', GRAV_LOG_PATH) ? GRAV_ROOT . '/' : '') . GRAV_LOG_PATH . '/');
  81. // END DEPRECATED
  82. // Some extensions
  83. define('CONTENT_EXT', '.md');
  84. define('TEMPLATE_EXT', '.html.twig');
  85. define('TWIG_EXT', '.twig');
  86. define('PLUGIN_EXT', '.php');
  87. define('YAML_EXT', '.yaml');
  88. // Content types
  89. define('RAW_CONTENT', 1);
  90. define('TWIG_CONTENT', 2);
  91. define('TWIG_CONTENT_LIST', 3);
  92. define('TWIG_TEMPLATES', 4);