8000 [BUG] [Symfony 3.0] [PHP 7] Cannot declare class Locale, because the name is already in use · Issue #20532 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[BUG] [Symfony 3.0] [PHP 7] Cannot declare class Locale, because the name is already in use #20532

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

Closed
RubenHarms opened this issue Nov 16, 2016 · 22 comments

Comments

@RubenHarms
Copy link
RubenHarms commented Nov 16, 2016

I got the following error in the console, when using a translation within a twig file (not sure if it's only in twig):

Cannot declare class Locale, because the name is already in use.

Exception trace:
 () at /var/www/domains/rsaleads/vendor/symfony/symfony/src/Symfony/Component/Intl/Resources/stubs/Locale.php:23

Info about environment:

PHP 7.0.13-1+deb.sury.org~xenial+1 (cli) ( NTS )
Symfony 3.0.1

@RubenHarms RubenHarms changed the title [BUG] Cannot declare class Locale, because the name is already in use [BUG] [Symfony 3.0] [PHP 7] Cannot declare class Locale, because the name is already in use Nov 16, 2016
@xabbuh
Copy link
Member
xabbuh commented Nov 16, 2016

This looks weird. Can you explain which step you performed that ended up here? Did you switch PHP versions, but did not clear the cache?

@RubenHarms
Copy link
Author
RubenHarms commented Nov 16, 2016

First I upgraded to 3.0.1, after a succesful upgrade, i switched to PHP 7.0. I can confirm this issue is not a cache issue. I forced cleared the cache by removing the folder cache content (rm ./var/cache/prod/; rm ./var/cache/dev/), but that does not solve anything.

@RubenHarms
Copy link
Author
RubenHarms commented Nov 17, 2016

I got the issue!

The following rule causes the error:
$c = \Symfony\Component\Locale\Locale::getDisplayCountries('nl');

I replaced the code with the following code:
$c = Intl::getRegionBundle()->getCountryNames('nl');

But this strange (Declare) error should not may appear!

@thi3rry
Copy link
thi3rry commented Dec 31, 2016

Same here with Symfony 3.2, PHP 7.0.14-2+deb.sury.org~xenial+1
but with Response class

Cannot declare class Symfony\Component\HttpFoundation\Response, because the name is already in use in /var/www/var/cache/prod/classes.php on line 4479

In prod environment it seems to appear when using the HttpCache with AppCache().

@thi3rry
Copy link
thi3rry commented Dec 31, 2016

Well, I found this issue with the use of FOSHttpCacheBundle FriendsOfSymfony/FOSHttpCacheBundle#276

I use this gist https://gist.github.com/pestaa/d544870c8bf7c9ecdc1cb999ac918cbb to solve the problem.

@mvrhov
Copy link
mvrhov commented Dec 31, 2016

afair this is because of a hard to reproduce bug in opcache try completely disabling it.

@nicolas-grekas
Copy link
Member

@thi3rry your issue is different and should be solved by #21184
@RubenHarms can we close this issue then?

@jakzal
Copy link
Contributor
jakzal commented Feb 1, 2017

Closing due to no response.

@RubenHarms feel free to come back with more details and we'll re-open.

@jakzal jakzal closed this as completed Feb 1, 2017
@krazygit
Copy link
krazygit commented May 16, 2017

I got the same issue with Symfony\Component\Config\ConfigCacheInterface

PHP Fatal error: Cannot declare interface Symfony\Component\Config\ConfigCacheInterface, because the name is already in use in /home/Myproject/var/cache/web/prod/classes.php

Env:
SF 3.2.8 + php7.1.5

When I run cache clear the prod/classes.php generated cause this strange error.
But when I just delete the cache directory and run the App every thing ok...or

./docker-console.sh cache:clear --env prod --no-debug
=> bug :(
./docker-console.sh cache:clear --env prod --no-debug --no-warmup
==> ok :)

@sstok
Copy link
Contributor
sstok commented Aug 27, 2017

@krazygit try upgrading to Symfony 3.3 (3.2 is end of maintenance (security patches only)), and remove this line https://github.com/symfony/symfony-standard/blob/3.3/web/app.php#L12

@NicoHaase
Copy link
Contributor

@sstok: if he is using PHP >= 7.0.0, as he states, line 12 should never be called

@xabbuh
Copy link
Member
xabbuh commented Aug 28, 2017

@NicoHaase Old versions of the Symfony Standard Edition didn't have this condition. So you need to make that change manually if you bootstrapped your project before the change was done in the repository.

@Bubelbub
Copy link

I still have this issue with Symfony 3.4 LTS.

@jakzal
Copy link
Contributor
jakzal commented Dec 14, 2017

@Bubelbub can you provide a full stack trace to show where's the error coming from?

@jakzal jakzal reopened this Dec 14, 2017
@nicolas-grekas
Copy link
Member
nicolas-grekas commented Dec 14, 2017

I would close here: this is the same as #25484, where I stated:

This issue is generally due to this: conflicting inlining strategies between boostrap.cache.php, classes.php and now maybe the inlined "include" in the container. Fortunately, we deprecated the two former, so this will die soon. Just don't use them and done.

@jakzal
Copy link
Contributor
jakzal commented Dec 14, 2017

Ok. @Bubelbub please try Nicolas' suggestion and come back if it didn't make your issue go away.

@jakzal jakzal closed this as completed Dec 14, 2017
@clementtalleu
Copy link
clementtalleu commented Aug 20, 2018

I still have this problem with sf 3.4. I try to fix it by modify my app_dev but it's not effective. (And I removed the boostrap.cache.php file)

@mendonca89dalton
Copy link

It gave me a similar problem and in the end I used php version 7.0.13 and symfony 3.1

@NicoHaase
Copy link
Contributor

It gave me a similar problem and in the end I used php version 7.0.13 and symfony 3.1

Have you tried updating both PHP and Symfony? Using completely outdated and no longer supported versions does not sound good

@kumar2112
Copy link

Hi all i am trying to create a new bundle in symfony 5 . so created and folder Core in src folder
mention namspace for in composer json file also register my bundle in bundles in bundle config .but when i try to run the app its shows me

Compile Error: Cannot declare class PortableAdmin\UserBundle\PortableAdminUserBundle, because the name is already in use

Please help me why its happening.

@xabbuh
Copy link
Member
xabbuh commented Apr 13, 2020

@kumar2112 For support, please refer to one of the support channels.

@Skiwa
Copy link
Skiwa commented May 12, 2021

This might help :

In my case, I simply changed Locale::getDisplayRegion($cc, 'fr')); to \Locale::getDisplayRegion($cc, 'fr'));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

0