bootstrap.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. //require dirname(__DIR__) . '/../Config/bootstrap.php';
  3. function find_root() {
  4. $root = dirname(__DIR__);
  5. if (is_dir($root . '/vendor/cakephp/cakephp')) {
  6. return $root;
  7. }
  8. $root = dirname(dirname(__DIR__));
  9. if (is_dir($root . '/vendor/cakephp/cakephp')) {
  10. return $root;
  11. }
  12. $root = dirname(dirname(dirname(__DIR__)));
  13. if (is_dir($root . '/vendor/cakephp/cakephp')) {
  14. return $root;
  15. }
  16. }
  17. define('DS', DIRECTORY_SEPARATOR);
  18. define('ROOT', dirname(dirname(dirname(dirname(__FILE__)))));
  19. define('APP_DIR', 'App');
  20. define('WEBROOT_DIR', 'webroot');
  21. define('APP', ROOT . DS . APP_DIR . DS);
  22. define('WWW_ROOT', ROOT . DS . WEBROOT_DIR . DS);
  23. define('TESTS', ROOT . DS . 'Test' . DS);
  24. define('TMP', ROOT . DS . 'tmp' . DS);
  25. define('LOGS', TMP . 'logs' . DS);
  26. define('CACHE', TMP . 'cache' . DS);
  27. define('CAKE_CORE_INCLUDE_PATH', ROOT . '/vendor/cakephp/cakephp');
  28. define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
  29. define('CAKE', CORE_PATH . 'src' . DS);
  30. require ROOT . '/vendor/cakephp/cakephp/src/basics.php';
  31. require ROOT . '/vendor/autoload.php';
  32. $TMP = new \Cake\Utility\Folder(TMP);
  33. $TMP->create(TMP . 'cache/models', 0777);
  34. $TMP->create(TMP . 'cache/persistent', 0777);
  35. $TMP->create(TMP . 'cache/views', 0777);
  36. $cache = [
  37. 'default' => [
  38. 'engine' => 'File'
  39. ],
  40. '_cake_core_' => [
  41. 'className' => 'File',
  42. 'prefix' => 'crud_myapp_cake_core_',
  43. 'path' => CACHE . 'persistent/',
  44. 'serialize' => true,
  45. 'duration' => '+10 seconds'
  46. ],
  47. '_cake_model_' => [
  48. 'className' => 'File',
  49. 'prefix' => 'crud_my_app_cake_model_',
  50. 'path' => CACHE . 'models/',
  51. 'serialize' => 'File',
  52. 'duration' => '+10 seconds'
  53. ]
  54. ];
  55. Cake\Cache\Cache::config($cache);
  56. Cake\Core\Plugin::load('Tools', ['path' => './']);
  57. $datasources = [
  58. 'test' => [
  59. 'className' => 'Cake\Database\Connection',
  60. 'driver' => 'Cake\Database\Driver\Mysql',
  61. 'persistent' => false,
  62. 'host' => 'localhost',
  63. 'login' => 'tools',
  64. 'password' => 'tools',
  65. 'database' => 'tools',
  66. 'prefix' => false,
  67. 'encoding' => 'utf8',
  68. ]
  69. ];
  70. $datasources['default'] = $datasources['test'];
  71. Cake\Datasource\ConnectionManager::config($datasources);