@@ -179,8 +179,8 @@ public function install()
179179 $ this ->checkCmsAdminEmail ();
180180 $ this ->checkCmsPassword ();
181181 $ this ->checkLanguage ();
182- $ this ->composerUpdate ();
183182 $ this ->realInstall ();
183+ $ this ->composerUpdate ();
184184 $ this ->checkRemoveInstall ();
185185 $ this ->removeInstall ();
186186 echo "\033[1;33;44mNow you use {$ this ->version }\033[0m " . PHP_EOL ;
@@ -383,47 +383,97 @@ public function checkIssetTablePrefix()
383383 }
384384 }
385385
386+ public function composerInstall ()
387+ {
388+ $ composerBin = EVO_CORE_PATH . 'vendor/bin/composer ' ;
389+
390+ if (is_file ($ composerBin )) {
391+ success ("✔ Using local Composer " );
392+ $ this ->runComposerCommand ('install ' );
393+ } else {
394+ warning ("⚠ Local Composer not found: {$ composerBin } Please run composer install manually. " );
395+ }
396+ }
397+
386398 public function composerUpdate ()
387399 {
388400 $ composerBin = EVO_CORE_PATH . 'vendor/bin/composer ' ;
401+
402+ if (is_file ($ composerBin )) {
403+ success ("✔ Running composer:update " );
404+ $ this ->runComposerCommand ('update ' );
405+ } else {
406+ warning ("⚠ Local Composer not found: {$ composerBin } Please run composer update manually. " );
407+ }
408+ }
409+
410+ public function checkAndWait ($ command )
411+ {
412+ $ criticalFiles = [
413+ 'vendor/autoload.php ' ,
414+ 'vendor/symfony/finder/Comparator/NumberComparator.php ' ,
415+ 'vendor/symfony/polyfill-mbstring/bootstrap.php ' ,
416+ 'vendor/symfony/deprecation-contracts/function.php ' ,
417+ ];
418+
419+ foreach ($ criticalFiles as $ file ) {
420+ $ fullPath = EVO_CORE_PATH . $ file ;
421+ $ tries = 0 ;
422+
423+ while (!is_file ($ fullPath ) && $ tries < 20 ) {
424+ $ tries ++;
425+ info ("⏳ Waiting for {$ file }... try {$ tries }" );
426+ usleep (3000000 );
427+ }
428+
429+ if (!is_file ($ fullPath )) {
430+ error ("✖ Required file missing after composer command: {$ file }" );
431+ warning ('⚠ Please run "composer ' . $ command . '" manually. ' );
432+ exit (1 );
433+ }
434+ }
435+ }
436+
437+ protected function runComposerCommand ($ command )
438+ {
439+ $ disabled = array_map ('trim ' , explode (', ' , ini_get ('disable_functions ' ) ?: '' ));
440+ $ composerBin = EVO_CORE_PATH . 'vendor/bin/composer ' ;
389441 $ workingDir = EVO_CORE_PATH ;
442+
390443 $ cmd = sprintf (
391- 'php %s update --no-interaction --prefer-dist --working-dir=%s ' ,
444+ 'php %s %s --no-interaction --prefer-dist --working-dir=%s ' ,
392445 escapeshellarg ($ composerBin ),
446+ $ command ,
393447 escapeshellarg ($ workingDir )
394448 );
395449
396- if (!is_file ($ composerBin )) {
397- warning ("⚠ Local Composer not found: {$ composerBin } Please perform 'composer install' or 'composer update' manually. " );
398- return ;
399- }
400-
401- success ("✔ Usage local Composer " );
402- info (" Running: {$ cmd }" );
450+ $ exitCode = null ;
403451
404- $ disabled = array_map ('trim ' , explode (', ' , ini_get ('disable_functions ' ) ?: '' ));
452+ try {
453+ if (!in_array ('passthru ' , $ disabled , true )) {
454+ passthru ($ cmd , $ exitCode );
455+ } elseif (!in_array ('exec ' , $ disabled , true )) {
456+ exec ($ cmd . ' 2>&1 ' , $ out , $ exitCode );
457+ echo implode (PHP_EOL , $ out ), PHP_EOL ;
458+ } elseif (!in_array ('shell_exec ' , $ disabled , true )) {
459+ $ output = shell_exec ($ cmd . ' 2>&1 ' );
460+ echo $ output ;
461+ $ exitCode = (is_string ($ output ) && $ output !== '' ) ? 0 : 1 ;
462+ } else {
463+ warning ('⚠ passthru/exec/shell_exec are disabled in php.ini ' );
464+ warning ('⚠ Please run "composer ' . $ command . '" manually. ' );
465+ return ;
466+ }
405467
406- $ exitCode = null ;
407- if (!in_array ('passthru ' , $ disabled , true )) {
408- passthru ($ cmd , $ exitCode );
409- } elseif (!in_array ('exec ' , $ disabled , true )) {
410- exec ($ cmd . ' 2>&1 ' , $ out , $ exitCode );
411- echo implode (PHP_EOL , $ out ), PHP_EOL ;
412- } elseif (!in_array ('shell_exec ' , $ disabled , true )) {
413- $ output = shell_exec ($ cmd . ' 2>&1 ' );
414- $ exitCode = (is_string ($ output ) && $ output !== '' ) ? 0 : 1 ;
415- echo $ output ;
416- } else {
417- warning ('⚠ The passthru/exec/shell_exec functions are disabled in php.ini. ' );
418- warning (' Run "composer update" manually. ' );
419- return ;
420- }
468+ $ this ->checkAndWait ($ command );
421469
422- if ($ exitCode === 0 ) {
423- success ('✔ Dependencies updated successfully. ' );
424- } else {
425- error ("✖ Composer finished with the code {$ exitCode }. " );
426- warning (' Make sure you have execute permissions and try "composer update" manually. ' );
470+ if ($ exitCode === 0 ) {
471+ success ("✔ Composer {$ command } finished successfully. " );
472+ } else {
473+ error ("✖ Composer {$ command } failed with code {$ exitCode }. " );
474+ }
475+ } catch (\Throwable $ e ) {
476+ error ("✖ Exception while executing Composer {$ command }: " . $ e ->getMessage ());
427477 }
428478 }
429479
0 commit comments