There is a project on Silex that I got from a single developer, I am working on it and it was necessary to fasten the language localization, I have the structure of the vendor folder

(source: joxi.ru )
I load the composer require symfony/translation repository composer require symfony/translation , in the end I get the following:

 composer require symfony/translation Using version ^3.2 for symfony/translation ./composer.json has been updated Loading composer repositories with package information Updating dependencies (including require-dev) - Removing emberlabs/gravatarlib (dev-master) - Removing phpunit/phpunit (3.7.x-dev) - Removing phpunit/php-code-coverage (1.2.x-dev) - Removing phpunit/php-token-stream (dev-master) - Removing phpunit/phpunit-mock-objects (1.2.x-dev) - Removing doctrine/dbal (dev-master) - Removing doctrine/common (2.4.x-dev) - Removing doctrine/inflector (dev-master) - Removing doctrine/cache (dev-master) - Removing doctrine/collections (dev-master) - Removing doctrine/annotations (dev-master) - Removing doctrine/lexer (dev-master) - Removing symfony/validator (dev-master) - Removing symfony/serializer (dev-master) - Removing symfony/process (dev-master) - Removing symfony/monolog-bridge (dev-master) - Removing monolog/monolog (dev-master) - Removing symfony/finder (dev-master) - Removing symfony/css-selector (dev-master) - Removing symfony/browser-kit (dev-master) - Removing symfony/dom-crawler (dev-master) - Removing symfony/form (dev-master) - Removing symfony/options-resolver (dev-master) - Removing symfony/property-access (dev-master) - Removing symfony/locale (dev-master) - Removing symfony/intl (dev-master) - Removing symfony/icu (1.0.x-dev) - Removing symfony/security (dev-master) - Removing symfony/filesystem (dev-master) - Installing symfony/filesystem (v3.0.9) Loading from cache - Removing symfony/config (dev-master) - Installing symfony/config (v2.8.14) Loading from cache - Removing symfony/yaml (dev-master) - Installing symfony/yaml (v2.8.14) Loading from cache - Installing symfony/polyfill-mbstring (v1.3.0) Loading from cache - Removing symfony/translation (dev-master) - Installing symfony/translation (v3.2.0) Loading from cache - Removing swiftmailer/swiftmailer (dev-master) - Installing swiftmailer/swiftmailer (v5.4.4) Loading from cache - Removing symfony/stopwatch (dev-master) - Installing symfony/stopwatch (v2.8.14) Loading from cache - Removing symfony/twig-bridge (dev-master) - Installing symfony/twig-bridge (v2.8.14) Loading from cache - Removing symfony/routing (dev-master) - Installing symfony/routing (v3.0.9) Loading from cache - Removing symfony/http-foundation (dev-master) - Installing symfony/http-foundation (v3.0.9) Loading from cache - Removing symfony/event-dispatcher (dev-master) - Installing symfony/event-dispatcher (v3.0.9) Loading from cache - Removing symfony/debug (dev-master) - Installing symfony/debug (v3.2.0) Loading from cache - Removing symfony/http-kernel (dev-master) - Installing symfony/http-kernel (v3.0.9) Loading from cache - Removing symfony/web-profiler-bundle (dev-master) - Installing symfony/web-profiler-bundle (v2.8.14) Loading from cache - Updating pimple/pimple (1.1.x-dev bc2fc12 => v1.1.1) Checking out 2019c145fe393923f3441b23f29bbdfaa5c58c4d - Installing silex/silex (v1.3.5) Loading from cache Package kilte/silex-captcha is abandoned, you should avoid using it. Use amstaffix/silex-captcha instead. Generating autoload files 

When I open the application, I naturally get an error:

 Fatal error: Uncaught exception 'ReflectionException' with message 'Class Symfony\Component\Security\Http\Firewall\ContextListener does not exist' in \vendor\silex\silex\src\Silex\Provider\SecurityServiceProvider.php:78 Stack trace: #0 \vendor\silex\silex\src\Silex\Provider\SecurityServiceProvider.php(78): ReflectionMethod->__construct('Symfony\\Compone...', '__construct') #1 \vendor\silex\silex\src\Silex\Application.php(178): Silex\Provider\SecurityServiceProvider->register(Object(Silex\Application)) #2 \src\app.php(138): Silex\Application->register(Object(Silex\Provider\SecurityServiceProvider), Array) #3 \site.ru\index.php(12): require('C:\\OpenServer\\g...') #4 {main} thrown in \vendor\silex\silex\src\Silex\Provider\SecurityServiceProvider.php on line 78 

Found several solutions to this problem.

  1. Using --prefer-dist - did not help.
  2. Add vendor to .gitignore - the result is the same.
  3. Delete all .git from the directory - to no avail.
  • I would have looked at composer.json + composer.lock with pleasure, most likely you are somehow using the composer incorrectly ... - AmsTaFFix

1 answer 1

These packages were probably removed from the composer.json file, but are also present in the ./vendor/composer/installed.json file. The latter is used to store the list of installed packages.

Comparing these 2 files, the composer will determine which packages have been removed from composer.json "manually" and remove them from the vendor folder.

Delete the entries related to the packages you want to keep from installed.json file.

  • Many thanks for the help, I thought that the problem did not solve at all! - edvardpotter