How to create ObjectManager service with Symfony2?
<p>At beginning, I used repository.</p>

<p>But, after some code reviews on github, I'm interesting to use ObjectManager (to alleviate controllers, and also by curiosity ^^).</p>

<p>The problem is I didn't see some good tutorial about it. Even tutorials I saw was to initialize a service by an object manager but not to create one.</p>

<p>In the FriendsOfSymfony github, we could see an example for that but I don't really understand how to initialize the service. I have this error "Cannot instantiate interface Doctrine\Common\Persistence\ObjectManager" when I initialize my manager service like this:</p>

<pre><code>&lt;?xml version="1.0" ?&gt;
</code></pre>

<p>http://symfony.com/schema/dic/services/services-1.0.xsd"></p>

<pre><code>&lt;parameters&gt;
    &lt;parameter key="md_mechanical.entity.enginemanager.class"&gt;MD\MechanicalBundle\Entity\EngineManager&lt;/parameter&gt;
&lt;/parameters&gt;

&lt;services&gt;
    &lt;service id="md_mechanical.enginemanager.default" class="%md_mechanical.entity.enginemanager.class%"&gt;
        &lt;argument type="service" id="md_mechanical.object_manager" /&gt;
        &lt;argument&gt;%md_engine.engine.class%&lt;/argument&gt;
    &lt;/service&gt;

    &lt;!-- The factory is configured in the DI extension class to support more Symfony versions --&gt;
    &lt;service id="md_mechanical.object_manager" class="Doctrine\Common\Persistence\ObjectManager"&gt;
        &lt;argument&gt;%fos_user.model_manager_name%&lt;/argument&gt;
    &lt;/service&gt;
&lt;/services&gt;
</code></pre>

<p></p>

<p>thanks in advance for your help</p>