index.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. // uncomment the following block to debug this app
  3. /*
  4. defined('YII_DEBUG') or define('YII_DEBUG', true);
  5. defined('YII_ENV') or define('YII_ENV', 'dev');
  6. error_reporting(E_ALL);
  7. ini_set('display_errors','on');
  8. */
  9. define('YII_ENABLE_ERROR_HANDLER', false);
  10. require __DIR__ . '/../vendor/yiisoft/yii2/Yii.php';
  11. $config = [
  12. 'id' => 'benchmark',
  13. 'basePath' => __DIR__,
  14. 'components' => [
  15. // Functions are faster than array declarations,
  16. // since they avoid the cost of Dependency Injection.
  17. 'db' => function() {
  18. return new yii\db\Connection([
  19. 'dsn' => 'mysql:host=tfb-database;dbname=hello_world',
  20. 'username' => 'benchmarkdbuser',
  21. 'password' => 'benchmarkdbpass',
  22. 'charset' => 'utf8',
  23. 'attributes' => [
  24. PDO::ATTR_PERSISTENT => true,
  25. ],
  26. 'enableLogging' => false,
  27. 'enableProfiling' => false,
  28. 'enableSchemaCache' => true,
  29. 'schemaCache' => 'cache',
  30. 'schemaCacheDuration' => 3600,
  31. ]);
  32. },
  33. 'cache' => function() {
  34. return new yii\caching\FileCache([
  35. 'cachePath' => '/tmp/yii2-cache',
  36. 'gcProbability' => 0,
  37. ]);
  38. },
  39. 'urlManager' => function() {
  40. return new yii\web\UrlManager([
  41. 'enablePrettyUrl' => true,
  42. ]);
  43. },
  44. // These components are overloaded for a small gain in performance (no DI)
  45. 'request' => function() { return new yii\web\Request(); },
  46. 'response' => function() { return new yii\web\Response(); },
  47. ],
  48. ];
  49. (new yii\web\Application($config))->run();