New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fatal error: Cannot redeclare class Symfony\Component\HttpFoundation\Response (or ResponseHeaderBag) #411
Comments
What version of |
@ieleja, do you clean the cache manually, without warmup? Try to use |
bash-3.2$ bin/console --version ============== bash-3.2$ php bin/console cache:clear --env=prod --no-debug // Clearing the cache for the prod environment with debug false [OK] Cache for the "prod" environment (debug=false) was successfully cleared. ============== after few successful clicks on Login/Logout/Homepage I get again: PHP Fatal error: Cannot redeclare class Symfony\Component\HttpFoundation\Response in /Users/User/Sites/symfony_demo/var/cache/prod/classes.php on line 3777 p.s. |
Same issue in Symfony 3.2.1. When viewing: /en/blog/ Fatal error: Cannot declare class Symfony\Component\HttpFoundation\ResponseHeaderBag, because the name is already in use in \var\cache\prod\classes.php on line 4491 Clearing the cache does fix it until you load another page. PHP 7.0.10 |
I'm getting the same issue on PHP 7.0 and 7.1 |
I can't reproduce with latest Symfony Demo + Symfony 3.2.1 + PHP 7.1 + macOS. Please, tell me the exact steps to reproduce it:
|
@javiereguiluz It occurs for me only with the
Anyway, for me, this error happens only with |
@bocharsky-bw thanks! I could reproduce it now. They key for me was: use the |
Yeah, it happens randomly... sometimes I need to repeat the navigation several times too. |
…on PHP 7 (bocharsky-bw) This PR was merged into the master branch. Discussion ---------- Fix error with class redeclaration: Do not load cache files on PHP 7 Fix #411 I think this error could be related to the symfony/symfony-standard#1030 Commits ------- 13da5dc Fix error with class redeclaration: Do not load cache files on PHP 7
Doesn't seem to be PHP 7 specific issue. I can reproduce the problem following steps by bocharsky-bw with PHP 5.6.23, OS X, Symfony 3.2.1 |
Reopening and kindly asking @nicolas-grekas to take a look at this because this seems like a very tricky bug. Thanks! |
Hm, seems it's due to this |
… (nicolas-grekas) This PR was merged into the 3.2 branch. Discussion ---------- [FrameworkBundle] Remove Response* from classes to compile | Q | A | ------------- | --- | Branch? | 3.2 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #20560, symfony/demo#411, FriendsOfSymfony/FOSHttpCacheBundle#276 | License | MIT | Doc PR | - When HttpCache is used, Response is loaded first, then the kernel is booted (on cache miss), which triggers the loading of classes.php. Since 3.2 generates a context free classes.php, the Response class is now included there when it was excluded previously. And boom, "Cannot declare class Symfony\Component\HttpFoundation\Response". Commits ------- 9ab5982 [FrameworkBundle] Remove Response* from classes to compile
[Symfony\Component\Debug\Exception\FatalErrorException] |
This also happens with ConfigCacheInterface on classes.php |
@xexu which PHP version and Symfony Demo version are you using? |
I get this all the time now, except with a different class name. Note that Dev does not exhibit the issue.
I have to manually delete the cache folder in order to clear the cache. Symfony version 3.4 PHP 7.1 |
please open a new issue instead of commenting on an old closed issue (from before the 3.4 release). |
this error occur due to the twice of this code on the top Remove one |
OSX, Apache 2.4, PHP 5.6.27
Linux, Apache 2.4, PHP 5.6.28
clean Symfony Demo install with:
$ symfony demo
point browser to:
http://localhost/symfony_demo/web/en/blog/
choose:
Browse Application
Back to blog
and always get this Fatal error under OSX:
PHP Fatal error: Cannot redeclare class Symfony\Component\HttpFoundation\ResponseHeaderBag in /Users/User/Sites/symfony_demo/var/cache/prod/classes.php on line 4491
or
PHP Fatal error: Cannot redeclare class Symfony\Component\HttpFoundation\Response in /Users/User/Sites/symfony_demo/var/cache/prod/classes.php on line 3777
and under Linux:
PHP Fatal error: Cannot redeclare class Symfony\Component\HttpFoundation\ResponseHeaderBag in /var/www/symfony_demo/var/cache/prod/classes.php on line 4491
clearing cache helps exactly one time, up to server recreates cache files
error reproduces in Chrome, Firefox, Safari
The text was updated successfully, but these errors were encountered: