bootstrap.php 1.9 KB

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