66ini_set ('display_errors ' , 'stderr ' );
77require 'vendor/autoload.php ' ;
88
9- use CodeIgniter \CodeIgniter ;
10- use Spiral \Debug ;
119use Spiral \Goridge ;
1210use Spiral \RoadRunner ;
1311use SDPMlab \Ci4Roadrunner \Ci4ResponseBridge ;
1412use SDPMlab \Ci4Roadrunner \Ci4RequestBridge ;
1513use SDPMlab \Ci4Roadrunner \Debug \Exceptions ;
1614use SDPMlab \Ci4Roadrunner \Debug \Toolbar ;
15+ use SDPMlab \Ci4Roadrunner \Debug \Dumper ;
16+
1717// codeigniter4 public/index.php
1818$ minPHPVersion = '7.2 ' ;
1919if (phpversion () < $ minPHPVersion )
2020{
2121 die ("Your PHP version must be {$ minPHPVersion } or higher to run CodeIgniter. Current version: " . phpversion ());
2222}
2323unset($ minPHPVersion );
24- //強制使codeigniter 認為這是一般請求
25- function is_cli (){
24+
25+ /**
26+ * Is CLI?
27+ *
28+ * Test to see if a request was made from the command line.
29+ *
30+ * @return boolean
31+ */
32+ function is_cli (): bool {
2633 return false ;
2734}
35+
2836define ('FCPATH ' , __DIR__ . DIRECTORY_SEPARATOR );
2937$ pathsPath = FCPATH . 'app/Config/Paths.php ' ;
3038chdir (__DIR__ );
@@ -35,8 +43,17 @@ function is_cli(){
3543//worker setting
3644$ worker = new RoadRunner \Worker (new Goridge \StreamRelay (STDIN , STDOUT ));
3745$ psr7 = new RoadRunner \PSR7Client ($ worker );
38- $ dumper = new Debug \Dumper ();
39- $ dumper ->setRenderer (Debug \Dumper::ERROR_LOG , new Debug \Renderer \ConsoleRenderer ());
46+
47+ /**
48+ * Dump given value into target output.
49+ *
50+ * @param mixed $value Variable
51+ * @param string $target Possible options: OUTPUT, RETURN, ERROR_LOG, LOGGER.
52+ * @return string|null
53+ */
54+ function dump ($ value ,string $ target = "ERROR_LOG " ) : ?string {
55+ return Dumper::getInstance ()->dump ($ value ,$ target );
56+ }
4057
4158$ count = 0 ;
4259while ($ req = $ psr7 ->acceptRequest ()) {
@@ -52,7 +69,7 @@ function is_cli(){
5269 } catch (
5370 \Throwable $ e
5471 ){
55- $ dumper -> dump ((string )$ e, Debug \Dumper:: ERROR_LOG );
72+ dump ((string )$ e );
5673 $ psr7 ->getWorker ()->error ((string )$ e );
5774 }
5875
@@ -67,7 +84,7 @@ function is_cli(){
6784 }
6885 }
6986 } catch (\Throwable $ e ){
70- $ dumper -> dump ((string )$ e, Debug \Dumper:: ERROR_LOG );
87+ dump ((string )$ e );
7188 $ psr7 ->getWorker ()->error ((string )$ e );
7289 }
7390
@@ -94,7 +111,7 @@ function is_cli(){
94111 } catch (
95112 \Throwable $ e
96113 ){
97- $ dumper -> dump ((string )$ e, Debug \Dumper:: ERROR_LOG );
114+ dump ((string )$ e );
98115 $ psr7 ->getWorker ()->error ((string )$ e );
99116 }
100117}
0 commit comments