Question

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 
Was it helpful?

Solution 2

One needs to both configure the autoloader and point doctrine to the correct entities.

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/"
    }
},
...

OTHER TIPS

Only bundles can be registered. Bridges are just library with a specific task: making a 3rd party library ready to be implemented by a Bundle in the Symfony2 framework. Usually, this starts by creating a bundle which implements a library into the Symfony2 framework, then all reusable stuff which isn't specifically tied to the framework are extracted from the bundle and put in a bridge, so it also can be used on places where bundles are not used (e.g. Silex).

In your case it should work, if you correctly configured the autoloading. You never have to register a library to a framework in order to make PHP able to autoload it, that are 2 different things.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top