database.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. use Illuminate\Support\Str;
  3. return [
  4. /*
  5. |--------------------------------------------------------------------------
  6. | Default Database Connection Name
  7. |--------------------------------------------------------------------------
  8. |
  9. | Here you may specify which of the database connections below you wish
  10. | to use as your default connection for all database work. Of course
  11. | you may use many connections at once using the Database library.
  12. |
  13. */
  14. 'default' => env('DB_CONNECTION', 'mysql'),
  15. /*
  16. |--------------------------------------------------------------------------
  17. | Database Connections
  18. |--------------------------------------------------------------------------
  19. |
  20. | Here are each of the database connections setup for your application.
  21. | Of course, examples of configuring each database platform that is
  22. | supported by Laravel is shown below to make development simple.
  23. |
  24. |
  25. | All database work in Laravel is done through the PHP PDO facilities
  26. | so make sure you have the driver for your particular database of
  27. | choice installed on your machine before you begin development.
  28. |
  29. */
  30. 'connections' => [
  31. 'mysql' => [
  32. 'host' => env('DB_HOST', '127.0.0.1'),
  33. 'sticky' => true, // sticky是一个 可选值,它用于立即读取在当前请求周期内已写入数据库的记录。若 sticky 选项被启用,并且当前请求周期内执行过「写」操作,那么任何「读」操作都将使用「写」连接。这样可确保同一个请求周期内写入的数据可以被立即读取到,从而避免主从同步延迟导致数据不一致的问题。不过是否启用它,取决于应用程序的需求
  34. 'database' => env('DB_DATABASE', 'kailin'),
  35. 'username' => env('DB_USERNAME', 'kailin'),
  36. 'password' => env('DB_PASSWORD', ''),
  37. 'driver' => 'mysql',
  38. 'unix_socket' => env('DB_SOCKET', ''),
  39. 'charset' => 'utf8mb4', //utf8超集,兼容emoji
  40. 'collation' => 'utf8mb4_unicode_ci',
  41. 'prefix' => env('DB_PREFIX', 'kailin_'),
  42. 'prefix_indexes' => true,
  43. 'strict' => false,
  44. 'engine' => null,
  45. 'options' => extension_loaded('pdo_mysql') ? array_filter([
  46. PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
  47. ]) : [],
  48. ],
  49. ],
  50. /*
  51. |--------------------------------------------------------------------------
  52. | Migration Repository Table
  53. |--------------------------------------------------------------------------
  54. |
  55. | This table keeps track of all the migrations that have already run for
  56. | your application. Using this information, we can determine which of
  57. | the migrations on disk haven't actually been run in the database.
  58. |
  59. */
  60. 'migrations' => 'migrations',
  61. /*
  62. |--------------------------------------------------------------------------
  63. | Redis Databases
  64. |--------------------------------------------------------------------------
  65. |
  66. | Redis is an open source, fast, and advanced key-value store that also
  67. | provides a richer body of commands than a typical key-value system
  68. | such as APC or Memcached. Laravel makes it easy to dig right in.
  69. |
  70. */
  71. 'redis' => [
  72. 'client' => env('REDIS_CLIENT', 'phpredis'),
  73. 'options' => [
  74. 'cluster' => env('REDIS_CLUSTER', 'redis'),
  75. 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_redisdb'),
  76. ],
  77. 'default' => [
  78. 'url' => env('REDIS_URL'),
  79. 'host' => env('REDIS_HOST', '127.0.0.1'),
  80. 'password' => env('REDIS_PASSWORD', null),
  81. 'port' => env('REDIS_PORT', '6379'),
  82. 'database' => env('REDIS_DB', '0'),
  83. ],
  84. 'cache' => [
  85. 'url' => env('REDIS_URL'),
  86. 'host' => env('REDIS_HOST', '127.0.0.1'),
  87. 'password' => env('REDIS_PASSWORD', null),
  88. 'port' => env('REDIS_PORT', '6379'),
  89. 'database' => env('REDIS_CACHE_DB', '1'),
  90. ],
  91. ],
  92. ];