app.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. return [
  3. //Cors
  4. 'cors' => [
  5. 'origin' => env('CORS_ORIGIN', ''),
  6. 'switch' => envInt('CORS_SWITCH', 0),
  7. ],
  8. //Timezone
  9. 'timezone' => env('TIMEZONE', null),
  10. //Monitor
  11. 'monitor' => [
  12. 'switch' => envInt('MONITOR_SWITCH', 0),
  13. ],
  14. //Throttle
  15. 'throttle' => [
  16. 'metric' => function(\SwFwLess\components\http\Request $request){
  17. return $request->getRoute();
  18. },
  19. 'period' => envInt('THROTTLE_PERIOD', 60),
  20. 'throttle' => envInt('THROTTLE_THROTTLE', 10000),
  21. ],
  22. //RedLock
  23. 'red_lock' => [
  24. 'connection' => env('RED_LOCK_CONNECTION', 'red_lock'),
  25. ],
  26. //RateLimit
  27. 'rate_limit' => [
  28. 'connection' => env('RATE_LIMIT_CONNECTION', 'rate_limit'),
  29. ],
  30. //Cache
  31. 'cache' => [
  32. 'connection' => env('CACHE_CONNECTION', 'cache'), //redis connection
  33. 'update_lock_ttl' => envInt('CACHE_UPDATE_LOCK_TTL', 10),
  34. ],
  35. //Hot Reload
  36. 'hot_reload' => [
  37. 'switch' => envInt('HOT_RELOAD_SWITCH', 0),
  38. 'watch_dirs' => [
  39. __DIR__ . '/',
  40. __DIR__ . '/../app/',
  41. __DIR__ . '/../vendor/',
  42. __DIR__ . '/../',
  43. ],
  44. 'excluded_dirs' => [],
  45. 'watch_suffixes' => ['.php', '.env'],
  46. 'driver' => env('HOT_RELOAD_DRIVER', \Kwf\FileWatcher\Watcher::class), //HuangYi\Watcher\Watcher::class is another choice
  47. ],
  48. //Error handler
  49. 'error_handler' => [
  50. 'err_formatter' => function (\Throwable $e) {
  51. return nl2br($e->getMessage() . PHP_EOL . $e->getTraceAsString());
  52. },
  53. ],
  54. //Ip Restriction
  55. 'ip_restriction' => [
  56. 'ips' => env('IP_RESTRICTION_IPS'),
  57. 'api_prefix' => env('IP_RESTRICTION_API_PREFIX'),
  58. ],
  59. //Scheduler
  60. 'scheduler' => [
  61. // [
  62. // 'schedule' => '* * * * *',
  63. // 'jobs' => function () {
  64. // echo 'Every minute', PHP_EOL;
  65. // },
  66. // ],
  67. // [
  68. // 'schedule' => '*/2 * * * *',
  69. // 'jobs' => function () {
  70. // echo 'Every two minutes', PHP_EOL;
  71. // },
  72. // ],
  73. ],
  74. //You can turn off the switch to improve the performance
  75. 'route_di_switch' => envBool('ROUTE_DI_SWITCH', false),
  76. ];