goaop / goaop-symfony-bundle

[Outdated!] Integration bridge for Go! AOP framework and Symfony
55 stars 16 forks source link

Problems with symfony cache:(clear|warmup) #3

Closed psturm closed 8 years ago

psturm commented 9 years ago

First of all, awesome bundle, thanks a lot! "Go! AOP PHP" itself is working great, but we got some problems with cache clear and warmup in symfony.

cache:clear

app/console cache:clear --no-warmup works fine.

But, when running app/console cache:clear (with implicit warmup), i get:

[Symfony\Component\Debug\Exception\ContextErrorException]
Notice: Constant AOP_ROOT_DIR already defined 

When wrapping those with !defined('AOP_ROOT_DIR'), SourceTransformingLoader::register() fails with:

[RuntimeException] 
Stream filter already registered

As a quick'n'dirty hack, i wrapped the full AspectKernel->init() method with a check, if the constant is already defined. Which works for now.

cache:warmup

But the most important bug currently is in the warmup command. I get these errors (simplified some pathes):

[Symfony\Component\Config\Exception\FileLoaderLoadException]
File "/myproject/src/.../Doctrine/Orm/IdTrait.php" was not processed yet in my_project.authentication.controller 
(which is being imported from "/myproject/src/.../Resources/config/routing.yml").

[TokenReflection\Exception\BrokerException] File "/myproject/src/.../Doctrine/Orm/IdTrait.php" was not processed yet.  

On each warmup, more and more files end up in the cache, and it (currently) works on the 3rd try.


Some details of the current setup

# ./app/config/config.yml
...

go_aop:
  options:
    cache_dir: %kernel.cache_dir%/../%kernel.environment%-goaop
    container_class: Go\Core\GoAspectContainer
# ./composer.json
...
"require": {
    "php": ">=5.5",
    "symfony/symfony": "2.7.1",
    "doctrine/orm": "~2.5,>=2.5.0",
    "doctrine/doctrine-bundle": "~1.5",
    ...
    "goaop/framework": "dev-master",
    "goaop/goaop-symfony-bundle": "dev-master",
    "knplabs/doctrine-behaviors": "~1.1"
}