@@ -23,10 +23,26 @@ public function __construct(Project $project, ?ProcessRunner $runner = null)
2323
2424 public function checks (): array
2525 {
26+ $ iniPath = php_ini_loaded_file ();
27+ $ projectWritable = $ this ->projectWritable ();
2628 $ checks = [
2729 $ this ->check ('PHP 8+ ' , PHP_VERSION_ID >= 80000 , PHP_VERSION ),
28- $ this ->check ('JSON extension ' , extension_loaded ('json ' ), extension_loaded ('json ' ) ? 'loaded ' : 'missing ' ),
30+ $ this ->check ('PHP CLI ' , PHP_SAPI === 'cli ' , PHP_SAPI ),
31+ $ this ->check ('PHP configuration ' , true , $ iniPath !== false ? $ iniPath : 'no php.ini loaded; using built-in defaults ' ),
32+ $ this ->extensionCheck ('JSON ' , 'json ' ),
33+ $ this ->extensionCheck ('OpenSSL ' , 'openssl ' , 'extension=openssl ' ),
34+ $ this ->extensionCheck ('Phar ' , 'phar ' ),
35+ $ this ->extensionCheck ('Filter ' , 'filter ' ),
36+ $ this ->extensionCheck ('Hash ' , 'hash ' ),
37+ $ this ->extensionCheck ('ZIP ' , 'zip ' , 'extension=zip ' ),
38+ $ this ->check (
39+ 'URL streams ' ,
40+ filter_var (ini_get ('allow_url_fopen ' ), FILTER_VALIDATE_BOOLEAN ),
41+ filter_var (ini_get ('allow_url_fopen ' ), FILTER_VALIDATE_BOOLEAN ) ? 'allow_url_fopen enabled ' : 'enable allow_url_fopen=On in php.ini '
42+ ),
2943 $ this ->check ('Process execution ' , function_exists ('proc_open ' ), function_exists ('proc_open ' ) ? 'available ' : 'proc_open is disabled ' ),
44+ $ this ->check ('Network sockets ' , function_exists ('fsockopen ' ), function_exists ('fsockopen ' ) ? 'available ' : 'fsockopen is disabled ' ),
45+ $ this ->check ('Project writable ' , $ projectWritable , $ projectWritable ? $ this ->project ->rootPath () : 'QuickInstall project directory is not writable ' ),
3046 ];
3147
3248 $ docker = $ this ->capture (['docker ' , 'version ' , '--format ' , '{{.Server.Version}} ' ]);
@@ -44,9 +60,15 @@ public function checks(): array
4460
4561 $ git = $ this ->capture (['git ' , '--version ' ]);
4662 $ checks [] = $ this ->check ('Git ' , $ git ['exit_code ' ] === 0 , $ this ->detail ($ git , 'not available ' ));
47- if (is_file ($ this ->project ->rootPath ('composer.phar ' )))
63+ $ composerPhar = $ this ->project ->rootPath ('composer.phar ' );
64+ if (is_file ($ composerPhar ))
4865 {
49- $ checks [] = $ this ->check ('Composer ' , true , 'bundled composer.phar ' );
66+ $ composer = $ this ->capture ([PHP_BINARY , $ composerPhar , '--version ' , '--no-ansi ' ]);
67+ $ checks [] = $ this ->check (
68+ 'Composer ' ,
69+ $ composer ['exit_code ' ] === 0 ,
70+ $ composer ['exit_code ' ] === 0 ? 'bundled ' . $ this ->firstDetail ($ composer , 'composer.phar ' ) : $ this ->detail ($ composer , 'bundled composer.phar could not run ' )
71+ );
5072 }
5173 else
5274 {
@@ -57,6 +79,29 @@ public function checks(): array
5779 return $ checks ;
5880 }
5981
82+ private function extensionCheck (string $ label , string $ extension , ?string $ setting = null ): array
83+ {
84+ $ loaded = extension_loaded ($ extension );
85+ $ detail = 'loaded ' ;
86+ if (!$ loaded )
87+ {
88+ $ detail = "missing PHP $ extension extension " ;
89+ if ($ setting !== null )
90+ {
91+ $ iniPath = php_ini_loaded_file ();
92+ $ detail .= '; enable ' . $ setting . ' in ' . ($ iniPath !== false ? $ iniPath : 'php.ini ' );
93+ }
94+ }
95+
96+ return $ this ->check ("$ label extension " , $ loaded , $ detail );
97+ }
98+
99+ private function projectWritable (): bool
100+ {
101+ $ path = is_dir ($ this ->project ->workspacePath ()) ? $ this ->project ->workspacePath () : $ this ->project ->rootPath ();
102+ return is_dir ($ path ) && is_writable ($ path );
103+ }
104+
60105 private function capture (array $ command ): array
61106 {
62107 try
@@ -84,4 +129,15 @@ private function detail(array $result, string $fallback): string
84129 $ lines = preg_split ('/\R/ ' , $ output ) ?: [];
85130 return trim ((string ) end ($ lines ));
86131 }
132+
133+ private function firstDetail (array $ result , string $ fallback ): string
134+ {
135+ $ output = trim ((string ) ($ result ['output ' ] ?? '' ));
136+ if ($ output === '' )
137+ {
138+ return $ fallback ;
139+ }
140+ $ lines = preg_split ('/\R/ ' , $ output ) ?: [];
141+ return trim ((string ) reset ($ lines ));
142+ }
87143}
0 commit comments