App.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php declare(strict_types=1);
  2. /**
  3. * DuckPhp
  4. * From this time, you never be alone~
  5. */
  6. namespace DuckPhpBenchmark\System;
  7. use DuckPhp\DuckPhp;
  8. class App extends DuckPhp
  9. {
  10. //@override
  11. public $options = [
  12. 'use_setting_file' => true,
  13. 'path_config' => 'app/config',
  14. 'path_view' => 'app/view',
  15. //'skip_setting_file' => false,
  16. //'is_debug' => false, // debug mode is turn off
  17. //'error_404' => '_sys/error_404', // we use system error view
  18. //'error_500' => '_sys/error_500', // we use system error view
  19. //'error_debug' => '_sys/error_debug', // we use system error view
  20. ];
  21. //@override
  22. public function _ExitJson($ret, $exit = true)
  23. {
  24. // oh no , duckphp v1.2.7 is : static::header('Content-Type:text/json'); we hotfix it.
  25. static::header('Content-Type:application/json');
  26. $flag = JSON_UNESCAPED_UNICODE | JSON_NUMERIC_CHECK;
  27. if ($this->_IsDebug()) {
  28. $flag = $flag | JSON_PRETTY_PRINT;
  29. }
  30. echo json_encode($ret, $flag);
  31. if ($exit) {
  32. static::exit();
  33. }
  34. }
  35. }