lexik / LexikTranslationBundle

This Symfony bundle allow to import translation files content into the database and provide a GUI to edit translations.
MIT License
425 stars 262 forks source link

cache:warmup on linux requires mongodb? #25

Open dinamic opened 11 years ago

dinamic commented 11 years ago

I don't have mongodb installed, nor do I need it. Everything is stored within the mysql database. I have configured PHPCR as I'm trying out the symfony-cmf.

Consider the following output:

windows 7:

D:\vagrant\vms\pwn\projects\mysite\tags\2.0>php app\console cache:warmup -e=prod --no-debug
Warming up the cache for the prod environment with debug false

vagrant box running ubuntu:

vagrant@precise32:/vagrant/projects/mysite/tags/2.0$ php app/console cache:warmup -e=prod --no-debug
PHP Fatal error:  Class 'Doctrine\ODM\MongoDB\DocumentRepository' not found in /vagrant/projects/mysite/tags/2.0/vendor/lexik/translation-bundle/Lexik/Bundle/TranslationBundle/Document/FileRepository.php on line 13

Here's the stack generated by capifony while trying to issue deployment:

PHP Fatal error:  Class 'Doctrine\ODM\MongoDB\DocumentRepository' not found in /home/mysite/v2/shared/vendor/lexik/translation-bundle/Lexik/Bundle/TranslationBundle/Document/TransUnitRepository.php on line 16
PHP Stack trace:
PHP   1. {main}() /home/mysite/v2/releases/20130415130816/app/console:0
PHP   2. Symfony\Component\Console\Application->run($input = class Symfony\Component\Console\Input\ArgvInput { private $tokens = array (0 => 'cache:warmup', 1 => '-e=prod', 2 => '--no-debug'); private $parsed = NULL; protected $definition = class Symfony\Component\Console\Input\InputDefinition { private $arguments = array (...); private $requiredCount = 0; private $hasAnArrayArgument = FALSE; private $hasOptional = FALSE; private $options = array (...); private $shortcuts = array (...) }; protected $options = array (); protected $arguments = array (); protected $interactive = TRUE }, $output = *uninitialized*) /home/mysite/v2/releases/20130415130816/app/console:22
PHP   3. Symfony\Bundle\FrameworkBundle\Console\Application->doRun($input = class Symfony\Component\Console\Input\ArgvInput { private $tokens = array (0 => 'cache:warmup', 1 => '-e=prod', 2 => '--no-debug'); private $parsed = NULL; protected $definition = class Symfony\Component\Console\Input\InputDefinition { private $arguments = array (...); private $requiredCount = 0; private $hasAnArrayArgument = FALSE; private $hasOptional = FALSE; private $options = array (...); private $shortcuts = array (...) }; protected $options = array (); protected $arguments = array (); protected $interactive = TRUE }, $output = class Symfony\Component\Console\Output\ConsoleOutput { private $stderr = class Symfony\Component\Console\Output\StreamOutput { private $stream = resource(46) of type (stream); private ${Symfony\Component\Console\Output\Output}:verbosity = 1; private ${Symfony\Component\Console\Output\Output}:formatter = class Symfony\Component\Console\Formatter\OutputFormatter { ... } }; private ${Symfony\Component\Console\Output\StreamOutput}:stream = resource(40) of type (stream); private ${Symfony\Component\Console\Output\Output}:verbosity = 1; private ${Symfony\Component\Console\Output\Output}:formatter = class Symfony\Component\Console\Formatter\OutputFormatter { private $decorated = TRUE; private $styles = array (...); private $styleStack = class Symfony\Component\Console\Formatter\OutputFormatterStyleStack { ... } } }) /home/mysite/v2/shared/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:106
PHP   4. Symfony\Bundle\FrameworkBundle\Console\Application->registerCommands() /home/mysite/v2/shared/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:68
PHP   5. Symfony\Component\HttpKernel\Kernel->boot() /home/mysite/v2/shared/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:83
PHP   6. Symfony\Component\HttpKernel\Kernel->initializeContainer() /home/mysite/v2/releases/20130415130816/app/bootstrap.php.cache:378
PHP   7. Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerAggregate->warmUp($cacheDir = '/home/mysite/v2/releases/20130415130816/app/cache/prod') /home/mysite/v2/releases/20130415130816/app/bootstrap.php.cache:601
PHP   8. Symfony\Bridge\Doctrine\CacheWarmer\ProxyCacheWarmer->warmUp($cacheDir = '/home/mysite/v2/releases/20130415130816/app/cache/prod') /home/mysite/v2/shared/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmerAggregate.php:47
PHP   9. Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->getAllMetadata() /home/mysite/v2/shared/vendor/symfony/symfony/src/Symfony/Bridge/Doctrine/CacheWarmer/ProxyCacheWarmer.php:69
PHP  10. Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain->getAllClassNames() /home/mysite/v2/shared/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php:111
PHP  11. Doctrine\Common\Persistence\Mapping\Driver\AnnotationDriver->getAllClassNames() /home/mysite/v2/shared/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriverChain.php:132
PHP  12. require_once() /home/mysite/v2/shared/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/AnnotationDriver.php:194
    command finished in 8635ms
dinamic commented 11 years ago

I can't understand the OS-specific behavior. May be I'm missing something?

aistis- commented 9 years ago

I had a similar situation, but in my case PHPCR was the cause. It was mapping all documents, including and those in Lexik.

doctrine_phpcr:
    odm:
        auto_mapping: false
steve-todorov commented 9 years ago

@aistis- you are absolutely right. I'm also using PHPCR and setting auto_mapping to false seems to be making it work, but it breaks pretty much half of my project. Any other solution? Ping @cedric-g

aistis- commented 9 years ago

In my case, we are using just few ODM bundles, so it was not a big deal to map it manually. I would also prefer more cleaner solution while keeping auto_mapping: true :)

steve-todorov commented 9 years ago

Or you could just remove vendor/lexik/translation-bundle/Lexik/Bundle/TranslationBundle/Document which seems to be fixing it for me for now. (not the most elegant way to deal with it, but I don't have time to deal with all the mapping right now..)

dinamic commented 9 years ago

Has anyone cracked on why it behaviour varies between operating systems?

aistis- commented 9 years ago

@dinamic We are using Vagrant + Ubuntu too and we get this every first request or console call when cache is fully cleared. On the second request, it is working fine.

steve-todorov commented 9 years ago

I'm using the bundle on Linux and Windows machines with PHPCR and the problem is there in both environments. By default PHPCR auto maps all classes which are located in MyBundle/Document. The problem here is that LexikTranslationBundle has MangoDB classes there and that gets things messed up. I haven't been able to get it to work no matter how many requests I do. if I don't disable auto_mapping (as @aistis- suggested) or deleting the Document folder from the vendor's bundle it just throws the exception you mentioned.

aistis- commented 8 years ago

The problem persists in v3.1.1 Cannot test in on v4 as the app is must be compatible with Symfony 2.7 and PHP 5.4

Niiko commented 8 years ago

Same on v4.0

phiamo commented 6 years ago

https://github.com/lexik/LexikTranslationBundle/issues/232