bootstrap.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. if (!defined('DS')) {
  3. define('DS', DIRECTORY_SEPARATOR);
  4. }
  5. if (!defined('WINDOWS')) {
  6. if (DS == '\\' || substr(PHP_OS, 0, 3) === 'WIN') {
  7. define('WINDOWS', true);
  8. } else {
  9. define('WINDOWS', false);
  10. }
  11. }
  12. define('ROOT', dirname(__DIR__));
  13. define('TMP', ROOT . DS . 'tmp' . DS);
  14. define('LOGS', TMP . 'logs' . DS);
  15. define('CACHE', TMP . 'cache' . DS);
  16. define('APP', sys_get_temp_dir());
  17. define('APP_DIR', 'src');
  18. define('CAKE_CORE_INCLUDE_PATH', ROOT . '/vendor/cakephp/cakephp');
  19. define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
  20. define('CAKE', CORE_PATH . APP_DIR . DS);
  21. define('WWW_ROOT', ROOT . DS . 'webroot' . DS);
  22. define('CONFIG', dirname(__FILE__) . DS . 'config' . DS);
  23. ini_set('intl.default_locale', 'de-DE');
  24. require ROOT . '/vendor/autoload.php';
  25. require CORE_PATH . 'config/bootstrap.php';
  26. Cake\Core\Configure::write('App', [
  27. 'namespace' => 'App',
  28. 'encoding' => 'UTF-8']);
  29. Cake\Core\Configure::write('debug', true);
  30. Cake\Core\Configure::write('Config', [
  31. 'adminEmail' => 'test@example.com',
  32. 'adminName' => 'Mark']);
  33. Cake\Mailer\Email::setConfig('default', ['transport' => 'Debug']);
  34. Cake\Mailer\TransportFactory::setConfig('Debug', [
  35. 'className' => 'Debug'
  36. ]);
  37. mb_internal_encoding('UTF-8');
  38. $Tmp = new Cake\Filesystem\Folder(TMP);
  39. $Tmp->create(TMP . 'cache/models', 0770);
  40. $Tmp->create(TMP . 'cache/persistent', 0770);
  41. $Tmp->create(TMP . 'cache/views', 0770);
  42. $cache = [
  43. 'default' => [
  44. 'engine' => 'File',
  45. 'path' => CACHE
  46. ],
  47. '_cake_core_' => [
  48. 'className' => 'File',
  49. 'prefix' => 'crud_myapp_cake_core_',
  50. 'path' => CACHE . 'persistent/',
  51. 'serialize' => true,
  52. 'duration' => '+10 seconds'
  53. ],
  54. '_cake_model_' => [
  55. 'className' => 'File',
  56. 'prefix' => 'crud_my_app_cake_model_',
  57. 'path' => CACHE . 'models/',
  58. 'serialize' => 'File',
  59. 'duration' => '+10 seconds'
  60. ]
  61. ];
  62. Cake\Cache\Cache::setConfig($cache);
  63. Cake\Core\Plugin::load('Tools', ['path' => ROOT . DS, 'bootstrap' => true]);
  64. // Ensure default test connection is defined
  65. if (!getenv('db_class')) {
  66. putenv('db_class=Cake\Database\Driver\Sqlite');
  67. putenv('db_dsn=sqlite::memory:');
  68. //putenv('db_class=Cake\Database\Driver\Postgres');
  69. //putenv('db_dsn=postgres://postgres@127.0.0.1/test');
  70. }
  71. Cake\Datasource\ConnectionManager::setConfig('test', [
  72. 'className' => 'Cake\Database\Connection',
  73. 'driver' => getenv('db_class'),
  74. 'dsn' => getenv('db_dsn'),
  75. 'database' => getenv('db_database'),
  76. 'username' => getenv('db_username'),
  77. 'password' => getenv('db_password'),
  78. 'timezone' => 'UTC',
  79. 'quoteIdentifiers' => true,
  80. 'cacheMetadata' => true,
  81. ]);