libraries.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <?php
  2. /**
  3. * Lithium: the most rad php framework
  4. *
  5. * @copyright Copyright 2013, Union of RAD (http://union-of-rad.org)
  6. * @license http://opensource.org/licenses/bsd-license.php The BSD License
  7. */
  8. /**
  9. * The libraries file is where you configure the various plugins, frameworks, and other libraries
  10. * to be used by your application, including your application itself. This file also defines some
  11. * global constants used to tell Lithium where to find your application and support libraries
  12. * (including Lithium itself). It uses the `Libraries` class to add configurations for the groups of
  13. * classes used in your app.
  14. *
  15. * In Lithium, a _library_ is any collection of classes located in a single base directory, which
  16. * all share the same class-to-file naming convention, and usually a common class or namespace
  17. * prefix. While all collections of classes are considered libraries, there are two special types of
  18. * libraries:
  19. *
  20. * - **Applications**: Applications are libraries which follow the organizational conventions that
  21. * Lithium defines for applications (see `Libraries::locate()` and `Libraries::paths()`), and
  22. * which also include a web-accessible document root (i.e. the `webroot/` folder), and can
  23. * dispatch HTTP requests (i.e. through `webroot/index.php`).
  24. *
  25. * - **Plugins**: Plugins are libraries which generally follow the same organizational conventions
  26. * as applications, but are designed to be used within the context of another application. They
  27. * _may_ include a public document root for supporting assets, but this requires a symlink from
  28. * `libraries/<plugin-name>/webroot` to `<app-name>/webroot/<plugin-name>` (recommended for
  29. * production), or a media filter to load plugin resources (see `/config/bootstrap/media.php`).
  30. *
  31. * Note that a library can be designed as both an application and a plugin, but this requires some
  32. * special considerations in the bootstrap process, such as removing any `require` statements, and
  33. * conditionally defining the constants below.
  34. *
  35. * By default, libraries are stored in the base `/libraries` directory, or in the
  36. * application-specific `<app-name>/libraries` directory. Libraries can be loaded from either place
  37. * without additional configuration, but note that if the same library is in both directories, the
  38. * application-specific `libraries` directory will override the global one.
  39. *
  40. * The one exception to this is the _primary_ library, which is an application configured with
  41. * `'default' => true` (see below); this library uses the `LITHIUM_APP_PATH` constant (also defined
  42. * below) as its path. Note, however, that any library can be overridden with an arbitrary path by
  43. * passing the `'path'` key to its configuration. See `Libraries::add()` for more options.
  44. *
  45. * @see lithium\core\Libraries
  46. */
  47. /**
  48. * This is the path to your application's directory. It contains all the sub-folders for your
  49. * application's classes and files. You don't need to change this unless your webroot folder is
  50. * stored outside of your app folder.
  51. */
  52. define('LITHIUM_APP_PATH', dirname(dirname(__DIR__)));
  53. /**
  54. * This is the path to the class libraries used by your application, and must contain a copy of the
  55. * Lithium core. By default, this directory is named `libraries`, and resides in the same
  56. * directory as your application. If you use the same libraries in multiple applications, you can
  57. * set this to a shared path on your server.
  58. */
  59. define('LITHIUM_LIBRARY_PATH', dirname(LITHIUM_APP_PATH) . '/libraries');
  60. /**
  61. * Locate and load Lithium core library files. Throws a fatal error if the core can't be found.
  62. * If your Lithium core directory is named something other than `lithium`, change the string below.
  63. */
  64. if (!include LITHIUM_LIBRARY_PATH . '/lithium/core/Libraries.php') {
  65. $message = "Lithium core could not be found. Check the value of LITHIUM_LIBRARY_PATH in ";
  66. $message .= __FILE__ . ". It should point to the directory containing your ";
  67. $message .= "/libraries directory.";
  68. throw new ErrorException($message);
  69. }
  70. use lithium\core\Libraries;
  71. /**
  72. * Optimize default request cycle by loading common classes. If you're implementing custom
  73. * request/response or dispatch classes, you can safely remove these. Actually, you can safely
  74. * remove them anyway, they're just there to give slightly you better out-of-the-box performance.
  75. */
  76. require LITHIUM_LIBRARY_PATH . '/lithium/core/Object.php';
  77. require LITHIUM_LIBRARY_PATH . '/lithium/core/StaticObject.php';
  78. require LITHIUM_LIBRARY_PATH . '/lithium/util/Collection.php';
  79. require LITHIUM_LIBRARY_PATH . '/lithium/util/collection/Filters.php';
  80. require LITHIUM_LIBRARY_PATH . '/lithium/util/Inflector.php';
  81. require LITHIUM_LIBRARY_PATH . '/lithium/util/String.php';
  82. require LITHIUM_LIBRARY_PATH . '/lithium/core/Adaptable.php';
  83. require LITHIUM_LIBRARY_PATH . '/lithium/core/Environment.php';
  84. require LITHIUM_LIBRARY_PATH . '/lithium/net/Message.php';
  85. require LITHIUM_LIBRARY_PATH . '/lithium/net/http/Message.php';
  86. require LITHIUM_LIBRARY_PATH . '/lithium/net/http/Media.php';
  87. require LITHIUM_LIBRARY_PATH . '/lithium/net/http/Request.php';
  88. require LITHIUM_LIBRARY_PATH . '/lithium/net/http/Response.php';
  89. require LITHIUM_LIBRARY_PATH . '/lithium/net/http/Route.php';
  90. require LITHIUM_LIBRARY_PATH . '/lithium/net/http/Router.php';
  91. require LITHIUM_LIBRARY_PATH . '/lithium/action/Controller.php';
  92. require LITHIUM_LIBRARY_PATH . '/lithium/action/Dispatcher.php';
  93. require LITHIUM_LIBRARY_PATH . '/lithium/action/Request.php';
  94. require LITHIUM_LIBRARY_PATH . '/lithium/action/Response.php';
  95. require LITHIUM_LIBRARY_PATH . '/lithium/template/View.php';
  96. require LITHIUM_LIBRARY_PATH . '/lithium/template/view/Renderer.php';
  97. require LITHIUM_LIBRARY_PATH . '/lithium/template/view/Compiler.php';
  98. require LITHIUM_LIBRARY_PATH . '/lithium/template/view/adapter/File.php';
  99. require LITHIUM_LIBRARY_PATH . '/lithium/storage/Cache.php';
  100. require LITHIUM_LIBRARY_PATH . '/lithium/storage/cache/adapter/Apc.php';
  101. /**
  102. * Add the Lithium core library. This sets default paths and initializes the autoloader. You
  103. * generally should not need to override any settings.
  104. */
  105. Libraries::add('lithium');
  106. /**
  107. * Add the application. You can pass a `'path'` key here if this bootstrap file is outside of
  108. * your main application, but generally you should not need to change any settings.
  109. */
  110. Libraries::add('app', array('default' => true));
  111. /**
  112. * Add some plugins:
  113. */
  114. // Libraries::add('li3_docs');
  115. ?>