databases.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * This file is part of Hyperf.
  5. *
  6. * @link https://www.hyperf.io
  7. * @document https://hyperf.wiki
  8. * @contact group@hyperf.io
  9. * @license https://github.com/hyperf/hyperf/blob/master/LICENSE
  10. */
  11. use function Hyperf\Support\env;
  12. return [
  13. 'default' => [
  14. 'driver' => env('DB_DRIVER', 'mysql'),
  15. 'host' => env('DB_HOST', 'localhost'),
  16. 'port' => env('DB_PORT', 3306),
  17. 'database' => env('DB_DATABASE', 'hyperf'),
  18. 'username' => env('DB_USERNAME', 'root'),
  19. 'password' => env('DB_PASSWORD', ''),
  20. 'charset' => env('DB_CHARSET', 'utf8mb4'),
  21. 'collation' => env('DB_COLLATION', 'utf8mb4_unicode_ci'),
  22. 'prefix' => env('DB_PREFIX', ''),
  23. 'pool' => [
  24. 'min_connections' => 1,
  25. 'max_connections' => 10,
  26. 'connect_timeout' => 10.0,
  27. 'wait_timeout' => 3.0,
  28. 'heartbeat' => -1,
  29. 'max_idle_time' => (float) env('DB_MAX_IDLE_TIME', 60),
  30. ],
  31. 'cache' => [
  32. 'handler' => Hyperf\ModelCache\Handler\RedisHandler::class,
  33. 'cache_key' => '{mc:%s:m:%s}:%s:%s',
  34. 'prefix' => 'default',
  35. 'ttl' => 3600 * 24,
  36. 'empty_model_ttl' => 600,
  37. 'load_script' => true,
  38. ],
  39. 'commands' => [
  40. 'gen:model' => [
  41. 'path' => 'app/Model',
  42. 'force_casts' => true,
  43. 'inheritance' => 'Model',
  44. 'uses' => '',
  45. 'table_mapping' => [],
  46. ],
  47. ],
  48. ],
  49. ];