Composer install error - jms-security-extra-bundle

332 Views Asked by At

I'm in the process of trying to upgrade a PHP application from Symfony 2.x to 3.x. I've managed to resolve dependency issues for the various packages we're using and all the packages download and install. However when the composer install triggers a cache clear it errors out with the following:

  [RuntimeException]
  An error occurred when executing the "'cache:clear --no-warmup'" command:


  Warning: Uncaught Symfony\Component\Debug\Exception\ContextErrorException: Warning: require_once(/home/vagrant/code/symfony/vendor/jms/security-extr
  a-bundle/Tests/Functional/../../vendor/autoload.php): failed to open stream: No such file or directory in /home/vagrant/code/symfony/vendor/jms/secu
  rity-extra-bundle/Tests/Functional/AppKernel.php:5
  Stack trace:
  #0 /home/vagrant/code/symfony/vendor/jms/security-extra-bundle/Tests/Functional/AppKernel.php(5): require_once()
  #1 /home/vagrant/code/symfony/vendor/symfony/symfony/src/Symfony/Component/Debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php(191): require_
  once('/home/vagrant/c...')
  #2 /home/vagrant/code/symfony/vendor/symfony/symfony/src/Symfony/Component/Debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php(145): Symfony\
  Component\Debug\FatalErrorHandler\ClassNotFoundFatalErrorHandler->convertFileToClass('/home/vagrant/c...', '/home/vagrant/c...', 'JMS\\SecurityExt..
  .')
  #3 /home/vagrant/code/symfony/vendor/symfony/symfony/src/Symfony/Component/Debug/Fata in /home/vagrant/code/symfony/vendor/jms/security-extra-bundle
  /Tests/Functional/AppKernel.php on line 5

  Fatal error: Symfony\Component\Debug\FatalErrorHandler\ClassNotFoundFatalErrorHandler::main(): Failed opening required '/home/vagrant/code/symfony/v
  endor/jms/security-extra-bundle/Tests/Functional/../../vendor/autoload.php' (include_path='.:/usr/share/php') in /home/vagrant/code/symfony/vendor/j
  ms/security-extra-bundle/Tests/Functional/AppKernel.php on line 5

The file it's referring to has these lines at the top:

<?php

namespace JMS\SecurityExtraBundle\Tests\Functional;

require_once __DIR__.'/../../vendor/autoload.php';

There is no autoload.php at that path. I suspect that this file is being autoloaded when it shouldn't be but I'm not sure how to resolve this.

I have compared the contents of the /vendor/jms/security-extra-bundle/Tests/Functional/AppKernel.php file to another Symfony 3 project that we have and it's exactly the same so this leads me to think it's even more likely that this file is being autoloaded when it shouldn't be.

What can I do to resolve this and get past the cache:clear --no-warmup command?

1

There are 1 best solutions below

0
PiX06 On

I have now resolved this. I had originally copied bin/console from another Symfony 3 project. It seems however that the correct approach was to move the existing app/console to the bin/console path and update the include paths to correctly reference the bootstrap.php.cache file in ../var/ and the autoload.php and AppKernel.php in ../app. The whole bin/console file now looks like this:

#!/usr/bin/env php
<?php

// if you don't want to setup permissions the proper way, just uncomment the following PHP line
// read http://symfony.com/doc/current/book/installation.html#configuration-and-setup for more information
//umask(0000);

set_time_limit(0);

require_once __DIR__.'/../var/bootstrap.php.cache';
require_once __DIR__.'/../app/autoload.php';
require_once __DIR__.'/../app/AppKernel.php';

use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Debug\Debug;

$input = new ArgvInput();
$env = $input->getParameterOption(array('--env', '-e'), getenv('SYMFONY_ENV') ?: 'dev');
$debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(array('--no-debug', '')) && $env !== 'prod';

if ($debug) {
    Debug::enable();
}

$kernel = new AppKernel($env, $debug);
$application = new Application($kernel);
$application->run($input);