bootstrap.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. define('DS', DIRECTORY_SEPARATOR);
  3. define('ROOT', dirname(__DIR__));
  4. define('TMP', ROOT . DS . 'tmp' . DS);
  5. define('LOGS', TMP . 'logs' . DS);
  6. define('CACHE', TMP . 'cache' . DS);
  7. define('APP', sys_get_temp_dir());
  8. define('APP_DIR', 'src');
  9. define('CAKE_CORE_INCLUDE_PATH', ROOT . '/vendor/cakephp/cakephp');
  10. define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
  11. define('CAKE', CORE_PATH . APP_DIR . DS);
  12. define('CONFIG', dirname(__FILE__) . DS . 'config' . DS);
  13. require ROOT . '/vendor/cakephp/cakephp/src/basics.php';
  14. require ROOT . '/vendor/autoload.php';
  15. Cake\Core\Configure::write('App', [
  16. 'namespace' => 'App',
  17. 'encoding' => 'UTF-8']);
  18. Cake\Core\Configure::write('debug', true);
  19. mb_internal_encoding('UTF-8');
  20. $Tmp = new \Cake\Filesystem\Folder(TMP);
  21. $Tmp->create(TMP . 'cache/models', 0770);
  22. $Tmp->create(TMP . 'cache/persistent', 0770);
  23. $Tmp->create(TMP . 'cache/views', 0770);
  24. $cache = [
  25. 'default' => [
  26. 'engine' => 'File'
  27. ],
  28. '_cake_core_' => [
  29. 'className' => 'File',
  30. 'prefix' => 'crud_myapp_cake_core_',
  31. 'path' => CACHE . 'persistent/',
  32. 'serialize' => true,
  33. 'duration' => '+10 seconds'
  34. ],
  35. '_cake_model_' => [
  36. 'className' => 'File',
  37. 'prefix' => 'crud_my_app_cake_model_',
  38. 'path' => CACHE . 'models/',
  39. 'serialize' => 'File',
  40. 'duration' => '+10 seconds'
  41. ]
  42. ];
  43. Cake\Cache\Cache::config($cache);
  44. Cake\Core\Plugin::load('Tools', ['path' => './']);
  45. // Ensure default test connection is defined
  46. if (!getenv('db_class')) {
  47. putenv('db_class=Cake\Database\Driver\Sqlite');
  48. putenv('db_dsn=sqlite::memory:');
  49. }
  50. Cake\Datasource\ConnectionManager::config('test', [
  51. 'className' => 'Cake\Database\Connection',
  52. 'driver' => getenv('db_class'),
  53. 'dsn' => getenv('db_dsn'),
  54. 'database' => getenv('db_database'),
  55. 'login' => getenv('db_login'),
  56. 'password' => getenv('db_password'),
  57. 'timezone' => 'UTC',
  58. 'quoteIdentifiers' => true,
  59. 'cacheMetadata' => true,
  60. ]);