databases.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. 'database' => env('DB_DATABASE', 'hyperf'),
  17. 'port' => env('DB_PORT', 3306),
  18. 'username' => env('DB_USERNAME', 'root'),
  19. 'password' => env('DB_PASSWORD', ''),
  20. 'charset' => env('DB_CHARSET', 'utf8'),
  21. 'collation' => env('DB_COLLATION', 'utf8_unicode_ci'),
  22. 'prefix' => env('DB_PREFIX', ''),
  23. 'logger' => [
  24. 'enabled' => true,
  25. 'name' => 'mysql',
  26. 'level' => 'debug',
  27. ],
  28. 'pool' => [
  29. 'min_connections' => 1,
  30. 'max_connections' => 10,
  31. 'connect_timeout' => 10.0,
  32. 'wait_timeout' => 3.0,
  33. 'heartbeat' => -1,
  34. 'max_idle_time' => (float) env('DB_MAX_IDLE_TIME', 60),
  35. ],
  36. 'variables' => [
  37. 'time_zone' => '+08:00', // 设置MySQL连接的时区
  38. ],
  39. 'commands' => [
  40. 'gen:model' => [
  41. 'path' => 'app/Model',
  42. 'force_casts' => true,
  43. 'inheritance' => 'Model',
  44. ],
  45. ],
  46. ],
  47. ];