Symfony 6 bunde uninstall twig error "The "xxx" directory does not exist (xxx)"

56 Views Asked by At

I am trying to install/uninstall package using Symfony Process and composer

$commands = [];
if ('1' == $installed) {
   $commands[] = ['php', '/usr/local/bin/composer', 'remove', $extensionName];
}

if ('0' == $installed) {
   $commands[] = ['php', '/usr/local/bin/composer', 'require', $extensionName];
}

foreach ($commands as $command) {
   $process = new Process($command);
   $process->setWorkingDirectory($kernel->getProjectDir());
   $process->setEnv([
       'COMPOSER_HOME' => $kernel->getProjectDir(),
   ]);
   $process->run();

   if (!$process->isSuccessful()) {
       throw new \RuntimeException($process->getErrorOutput());
   }
}

The install command works fine using Symfony process but on uninstall it throws erro: The "/var/www/vendor/xxx/paypal-bundle/templates" directory does not exist ("/var/www/vendor/xxx/paypal-bundle/templates").

Here is the bundle definition:

class PaypalBundle extends AbstractBundle
{
    public function prependExtension(ContainerConfigurator $container, ContainerBuilder $builder): void
    {
        $container->extension('twig', [
            'paths' => [
                '%kernel.project_dir%/vendor/xxx/paypal-bundle/templates' => 'PaypalBundle',
            ],
        ]);
        ...
    }
}

Running composer install/uninstall command manuallly works fine, But running via symfony process component doesn't work on uninstall.

0

There are 0 best solutions below