1515
1616use CodeIgniter \CLI \AbstractCommand ;
1717use CodeIgniter \CLI \Attributes \Command ;
18- use CodeIgniter \CLI \CLI ;
1918use CodeIgniter \CLI \Input \Option ;
19+ use CodeIgniter \CLI \Output ;
2020
2121/**
2222 * Installs the files needed to run CodeIgniter 4 in FrankenPHP worker mode.
@@ -49,10 +49,11 @@ protected function configure(): void
4949
5050 protected function execute (array $ arguments , array $ options ): int
5151 {
52- $ force = $ options ['force ' ] === true ;
52+ $ force = $ options ['force ' ] === true ;
53+ $ output = $ this ->getOutput ();
5354
54- CLI :: write ('Setting up FrankenPHP Worker Mode ' , 'yellow ' );
55- CLI :: newLine ();
55+ $ output -> write ('Setting up FrankenPHP Worker Mode ' , 'yellow ' );
56+ $ output -> newLine ();
5657
5758 helper ('filesystem ' );
5859
@@ -71,52 +72,52 @@ protected function execute(array $arguments, array $options): int
7172 $ content = file_get_contents ($ source );
7273
7374 if ($ content === false ) {
74- CLI :: error (sprintf ('Failed to read template: %s ' , $ template ), 'light_gray ' , 'red ' );
75+ $ output -> error (sprintf ('Failed to read template: %s ' , $ template ), 'light_gray ' , 'red ' );
7576
7677 return EXIT_ERROR ;
7778 }
7879
7980 if (! write_file ($ target , $ content )) {
80- CLI :: error (sprintf ('Failed to create file: %s ' , clean_path ($ target )), 'light_gray ' , 'red ' );
81+ $ output -> error (sprintf ('Failed to create file: %s ' , clean_path ($ target )), 'light_gray ' , 'red ' );
8182
8283 return EXIT_ERROR ;
8384 }
8485
8586 if ($ force && $ isFile ) {
86- CLI :: write (sprintf (' File overwritten: %s ' , clean_path ($ target )), 'yellow ' );
87+ $ output -> write (sprintf (' File overwritten: %s ' , clean_path ($ target )), 'yellow ' );
8788 } else {
88- CLI :: write (sprintf (' File created: %s ' , clean_path ($ target )), 'green ' );
89+ $ output -> write (sprintf (' File created: %s ' , clean_path ($ target )), 'green ' );
8990 }
9091
9192 $ created [] = $ destination ;
9293 }
9394
9495 if ($ created === []) {
95- CLI :: write ('Worker mode files already exist. ' , 'yellow ' );
96- CLI :: write ('Use --force to overwrite existing files. ' , 'yellow ' );
96+ $ output -> write ('Worker mode files already exist. ' , 'yellow ' );
97+ $ output -> write ('Use --force to overwrite existing files. ' , 'yellow ' );
9798
9899 return EXIT_ERROR ;
99100 }
100101
101- CLI :: newLine ();
102- CLI :: write ('Worker mode files created successfully! ' , 'green ' );
103- CLI :: newLine ();
102+ $ output -> newLine ();
103+ $ output -> write ('Worker mode files created successfully! ' , 'green ' );
104+ $ output -> newLine ();
104105
105- $ this ->showNextSteps ();
106+ $ this ->showNextSteps ($ output );
106107
107108 return EXIT_SUCCESS ;
108109 }
109110
110- private function showNextSteps (): void
111+ private function showNextSteps (Output $ output ): void
111112 {
112- CLI :: write ('Next Steps: ' , 'yellow ' );
113- CLI :: newLine ();
113+ $ output -> write ('Next Steps: ' , 'yellow ' );
114+ $ output -> newLine ();
114115
115- CLI :: write ('1. Start FrankenPHP: ' , 'white ' );
116- CLI :: write (' frankenphp run ' , 'green ' );
117- CLI :: newLine ();
116+ $ output -> write ('1. Start FrankenPHP: ' , 'white ' );
117+ $ output -> write (' frankenphp run ' , 'green ' );
118+ $ output -> newLine ();
118119
119- CLI :: write ('2. Test your application: ' , 'white ' );
120- CLI :: write (' curl http://localhost:8080/ ' , 'green ' );
120+ $ output -> write ('2. Test your application: ' , 'white ' );
121+ $ output -> write (' curl http://localhost:8080/ ' , 'green ' );
121122 }
122123}
0 commit comments