Twig: Error Cannot redeclare class Twig_Environment

I updated vendors, and only update version twig.

 - Removing twig/twig (1.x-dev 460712d)
  - Installing twig/twig (1.x-dev 04ef7a1)
    Loading from cache

But now I get the following error:

FatalErrorException in Environment.php line 17: Error: Cannot redeclare class Twig_Environment

I cleared cache… but the error continue… I did a compare two commits… but I dont see nothing unusual…

https://github.com/twigphp/Twig/compare/460712d...04ef7a1#diff-d4416d290253c72cec40c63f54354b16

any idea ?

This is my composer

	"require" : {
		"php" : "^5.6|^7.0",
		"ext-mcrypt" : "*",
		"twig/extensions" : "^1.4",
		"sensio/framework-extra-bundle" : "~3.0",
		"sensio/generator-bundle" : "~3.0",
		"symfony/assetic-bundle": "2.8.1",
		"incenteev/composer-parameter-handler" : "~2.0",
		"twbs/bootstrap" : "dev-master",
		"knplabs/knp-paginator-bundle" : "dev-master",
		"craue/formflow-bundle" : "2.1.8",
		"shtumi/useful-bundle" : "dev-master",
		"sonata-project/formatter-bundle" : "2.3.2",
		"sonata-project/doctrine-extensions" : "1.0.2",
		"frequence-web/contact-bundle" : "*",
		"jms/serializer-bundle" : "^1.1",
        "sylius/sylius": "1.0.0-alpha.2",
		"presta/sitemap-bundle" : "~1.3@dev",
		"beelab/recaptcha2-bundle" : "1.2.1",
		"dizda/cloud-backup-bundle" : "^3.2",
		"aws/aws-sdk-php" : "2.8.24",
		"lexik/maintenance-bundle" : "2.1.1",
		"hwi/oauth-bundle" : "0.3.x",
		"friendsofsymfony/rest-bundle" : "1.8.x",
		"crevillo/payum-redsys" : "^1.0",
		"payum/paypal-express-checkout-nvp" : "^1.3",
		"php-http/guzzle6-adapter" : "^1.1",
		"oyejorge/less.php": "v1.7.0.10",
		"doctrine/doctrine-cache-bundle": "^1.3",
		"predis/predis": "^1.1",
		"snc/redis-bundle": "^2.0",
		"knplabs/knp-gaufrette-bundle": "^0.3.0",
		"liip/imagine-bundle": "1.7.2",
		"phpdocumentor/reflection-docblock": "2.0.4"
	},
	"require-dev" : {
		"raulfraile/ladybug-bundle" : "~1.0",
		"behat/behat" : "~3.0",
		"behat/symfony2-extension" : "~2.0@dev",
		"behat/mink-extension" : "~2.0@dev",
		"behat/mink-browserkit-driver" : "~1.2@dev",
		"behat/mink-selenium2-driver" : "@dev",
		"behat/mink" : "~1.6@dev",
		"fzaninotto/faker" : "~1.2",
		"phpunit/phpunit" : "<=5.7",
		"visithor/visithor-bundle" : "^0.1.0@dev",
		"michaelmoussa/doctrine-qbmocker": "^0.12.0"
	},

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 30 (19 by maintainers)

Commits related to this issue

Most upvoted comments

Composer just updated me to 2.4.0 which I see just got released 20 minutes ago, and immediately received the error as well. I had 2.3.2 before

Here’s a stack trace:

in Environment.php line 17 in classes.php line 5503 in ClassCollectionLoader.php line 93 at ClassCollectionLoader::load() in Kernel.php line 384 at AppKernel->doLoadClassCache() in Kernel.php line 109 at AppKernel->boot() in Kernel.php line 165 at AppKernel->handle() in app_dev.php line 28 at {main}() in app_dev.php line 0

I made the PR 😃 See #2501

Similar to @richard4339 it just updated from 1.33.2 to 1.34.0 in a composer update and the same 500 error occurred. I reverted back to 1.33.2 and it has resolved the issue. Using Symfony 3.1 for reference.

@GuigZ- or @Chrysweel, in src/Environment.php, can you try replacing the “require” by “require_once” please? Any change? Would you be able to provide a reproducer?

Hey

I’ve a same problem. I fix it when I force twig to 1.33.2 in my composer.json

The 1.x.dev is not a release version, you can have bugs.

BR