0

I was trying to setup metabor/statemachine-doctrine-bridge within a symfony2 project. I am used to register new bundles, yet I have no clue how I would get symfony2 to find the bridge.

I tried including it via use statement but it seems to be not enough resulting in the error:

 [Doctrine\Common\Persistence\Mapping\MappingException]                                                                                                              
  The class 'Metabor\Bridge\Doctrine\Statemachine\State' was not found in the chain configured namespaces Hn\AssetDbBundle\Entity, Hn\UserBundle\Entity, FOS\UserBun  
  dle\Entity, FOS\UserBundle\Model 
4

2 回答 2

1

只能注册捆绑包。Bridges 只是具有特定任务的库:使 3rd 方库准备好由 Symfony2 框架中的 Bundle 实现。通常,这首先创建一个在 Symfony2 框架中实现库的包,然后从包中提取所有与框架无关的可重用内容并放在桥中,因此它也可以在以下地方使用不使用捆绑包(例如 Silex)。

在您的情况下,如果您正确配置了自动加载,它应该可以工作。您永远不必将库注册到框架以使 PHP 能够自动加载它,这是两件不同的事情。

于 2014-02-19T15:40:59.040 回答
0

需要同时配置自动装载机并将理论指向正确的实体。

app/config.yml

orm:
    auto_generate_proxy_classes: "%kernel.debug%"
    auto_mapping: true
    mappings:
        MetaborBridge:
            type: annotation
            dir: %kernel.root_dir%/../vendor/metabor/statemachine-doctrine-bridge/src/Metabor
            prefix: Metabor
            is_bundle: false 

composer.json

...
"autoload": {
    "psr-0": {
        "": "src/",
        "Metabor": "vendor/metabor/statemachine-doctrine-bridge/src/Metabor/",
        "MetaborStd": "vendor/metabor/metabor-std/src/MetaborStd/"
    }
},
...
于 2014-02-24T09:54:11.160 回答