helpers.php 875 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace {
  3. if (!function_exists('swoole_cpu_num')) {
  4. function swoole_cpu_num(): int
  5. {
  6. return 1;
  7. }
  8. }
  9. if (!defined('SWOOLE_SOCK_TCP')) {
  10. define('SWOOLE_SOCK_TCP', 1);
  11. }
  12. if (!defined('SWOOLE_PROCESS')) {
  13. define('SWOOLE_PROCESS', 3);
  14. }
  15. if (!defined('SWOOLE_HOOK_ALL')) {
  16. define('SWOOLE_HOOK_ALL', 1879048191);
  17. }
  18. }
  19. namespace think\swoole\helper {
  20. use think\swoole\response\File;
  21. function download(string $filename, string $name = '', $disposition = File::DISPOSITION_ATTACHMENT): File
  22. {
  23. $response = new File($filename, $disposition);
  24. if ($name) {
  25. $response->setContentDisposition($disposition, $name);
  26. }
  27. return $response;
  28. }
  29. function file(string $filename)
  30. {
  31. return new File($filename);
  32. }
  33. }