2
0

database.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <?php
  2. use Illuminate\Support\Str;
  3. use Illuminate\Support\Facades\Log;
  4. $config = [
  5. /*
  6. |--------------------------------------------------------------------------
  7. | Default Database Connection Name
  8. |--------------------------------------------------------------------------
  9. |
  10. | Here you may specify which of the database connections below you wish
  11. | to use as your default connection for all database work. Of course
  12. | you may use many connections at once using the Database library.
  13. |
  14. */
  15. 'default' => env('DB_CONNECTION', 'mysql'),
  16. /*
  17. |--------------------------------------------------------------------------
  18. | Database Connections
  19. |--------------------------------------------------------------------------
  20. |
  21. | Here are each of the database connections setup for your application.
  22. | Of course, examples of configuring each database platform that is
  23. | supported by Laravel is shown below to make development simple.
  24. |
  25. |
  26. | All database work in Laravel is done through the PHP PDO facilities
  27. | so make sure you have the driver for your particular database of
  28. | choice installed on your machine before you begin development.
  29. |
  30. */
  31. 'connections' => [
  32. 'sqlite' => [
  33. 'driver' => 'sqlite',
  34. 'url' => env('DATABASE_URL'),
  35. 'database' => env('DB_DATABASE', database_path('database.sqlite')),
  36. 'prefix' => '',
  37. 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
  38. ],
  39. 'mysql' => [
  40. 'driver' => 'mysql',
  41. 'url' => env('DATABASE_URL'),
  42. 'host' => env('DB_HOST', '127.0.0.1'),
  43. 'port' => env('DB_PORT', '3306'),
  44. 'database' => env('DB_DATABASE', 'forge'),
  45. 'username' => env('DB_USERNAME', 'forge'),
  46. 'password' => env('DB_PASSWORD', ''),
  47. 'unix_socket' => env('DB_SOCKET', ''),
  48. 'charset' => 'utf8mb4',
  49. 'collation' => 'utf8mb4_unicode_ci',
  50. 'prefix' => '',
  51. 'prefix_indexes' => true,
  52. 'strict' => true,
  53. 'engine' => null,
  54. 'options' => extension_loaded('pdo_mysql') ? array_filter([
  55. PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
  56. ]) : [],
  57. ],
  58. 'pgsql' => [
  59. 'driver' => 'pgsql',
  60. 'url' => env('DATABASE_URL'),
  61. 'host' => env('DB_HOST', '127.0.0.1'),
  62. 'port' => env('DB_PORT', '5432'),
  63. 'database' => env('DB_DATABASE', 'forge'),
  64. 'username' => env('DB_USERNAME', 'forge'),
  65. 'password' => env('DB_PASSWORD', ''),
  66. 'charset' => 'utf8',
  67. 'prefix' => '',
  68. 'prefix_indexes' => true,
  69. 'schema' => 'public',
  70. 'sslmode' => 'prefer',
  71. ],
  72. 'sqlsrv' => [
  73. 'driver' => 'sqlsrv',
  74. 'url' => env('DATABASE_URL'),
  75. 'host' => env('DB_HOST', 'localhost'),
  76. 'port' => env('DB_PORT', '1433'),
  77. 'database' => env('DB_DATABASE', 'forge'),
  78. 'username' => env('DB_USERNAME', 'forge'),
  79. 'password' => env('DB_PASSWORD', ''),
  80. 'charset' => 'utf8',
  81. 'prefix' => '',
  82. 'prefix_indexes' => true,
  83. ],
  84. ],
  85. /*
  86. |--------------------------------------------------------------------------
  87. | Migration Repository Table
  88. |--------------------------------------------------------------------------
  89. |
  90. | This table keeps track of all the migrations that have already run for
  91. | your application. Using this information, we can determine which of
  92. | the migrations on disk haven't actually been run in the database.
  93. |
  94. */
  95. 'migrations' => 'migrations',
  96. /*
  97. |--------------------------------------------------------------------------
  98. | Redis Databases
  99. |--------------------------------------------------------------------------
  100. |
  101. | Redis is an open source, fast, and advanced key-value store that also
  102. | provides a richer body of commands than a typical key-value system
  103. | such as APC or Memcached. Laravel makes it easy to dig right in.
  104. |
  105. */
  106. 'redis' => [
  107. 'client' => env('REDIS_CLIENT', 'phpredis'),
  108. 'options' => [
  109. 'cluster' => env('REDIS_CLUSTER', 'redis'),
  110. 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
  111. ],
  112. 'default' => [
  113. 'url' => env('REDIS_URL'),
  114. 'host' => env('REDIS_HOST', '127.0.0.1'),
  115. 'password' => env('REDIS_PASSWORD', null),
  116. 'port' => env('REDIS_PORT', '6379'),
  117. 'database' => env('REDIS_DB', '0'),
  118. ],
  119. 'cache' => [
  120. 'url' => env('REDIS_URL'),
  121. 'host' => env('REDIS_HOST', '127.0.0.1'),
  122. 'password' => env('REDIS_PASSWORD', null),
  123. 'port' => env('REDIS_PORT', '6379'),
  124. 'database' => env('REDIS_CACHE_DB', '1'),
  125. ],
  126. ],
  127. /*
  128. |--------------------------------------------------------------------------
  129. | snowflake id start date don't modify
  130. |--------------------------------------------------------------------------
  131. |
  132. |
  133. */
  134. 'snowflake' => [
  135. 'start'=>"2021-12-22",
  136. ],
  137. ];
  138. if(env('APP_ENV') !== 'local'){
  139. $config['redis'] = [
  140. 'client' => env('REDIS_CLIENT', 'phpredis'),
  141. 'options' => [
  142. 'cluster' => env('REDIS_CLUSTER', 'redis'),
  143. ],
  144. 'clusters' => [
  145. 'default' => [
  146. [
  147. 'host' => env('REDIS_HOST', '127.0.0.1'),
  148. 'password' => env('REDIS_PASSWORD', null),
  149. 'port' => env('REDIS_PORT', '6379'),
  150. 'database' => env('REDIS_DB', '0'),
  151. 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
  152. ],
  153. ],
  154. ],
  155. 'cache' => [
  156. 'host' => env('REDIS_CACHE_HOST', '127.0.0.1'),
  157. 'port' => env('REDIS_CACHE_PORT', '6379'),
  158. 'prefix' => env('REDIS_CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
  159. ],
  160. ];
  161. }
  162. return $config;