title: How to properly integrate a 3rd party library in a Symfony2 project
body: <p>I am working on a Symfony 2.2 Project in which I need to upload video to Vimeo. I am using advanced Vimeo API via the <a href="https://github.com/vimeo/vimeo-php-lib" rel="nofollow">Vimeo.php (official library of Vimeo)</a></p>
  
  <p>I managed to add a namespace to the library and added it to the entity folder in my bundle because that is the only way the project was detecting the library.</p>
  
  <pre><code>&lt;?php
  **namespace MediaBundle\Entity;**
  
  use Symfony\Component\Security\Core\Exception\InvalidCsrfTokenException as Exception;
  
  class Vimeo
  {
      .... Vimeo.php Code ....
  }
  ?&gt;
  </code></pre>
  
  <p>I am trying to find a better way to integrate this library in my code. I have tried to place in the vendor/vimeo folder and autoload it from app/autoload.php</p>
  
  <p><strong>Without Namespace:</strong></p>
  
  <pre><code>$loader-&gt;registerPrefixes(array(
      'Vimeo_' =&gt; __DIR__.'/../vendor/vimeo/lib',
  ));
  </code></pre>
  
  <p><strong>With Namespace:</strong></p>
  
  <pre><code>$loader-&gt;registerNamespaces(array(
      'Vimeo' =&gt; __DIR__.'/../vendor/vimeo/lib',
  ));
  </code></pre>
  
  <p>The class is still not recognized in the controller.</p>
  
  <p>To automate the process I tried using a composer package <a href="https://github.com/dukt/vimeo" rel="nofollow">dukt/vimeo</a>, it is basically the same library just wrapper into composer. It places it in the autoload_namespaces.php, but I am still unable to use it in any controller. It is always not found.</p>
  
  <p>Perhaps I am not putting the correct use statement. The autoload_namespaces.php code is:</p>
  
  <pre><code>'Dukt\\Vimeo' =&gt; $vendorDir . '/dukt/vimeo/src/',
  </code></pre>
  
  <p>There is a Vimeo.php class in <code>/dukt/vimeo/src</code> with <code>namespace Dukt;</code>. What should be my use statement in the controller?</p>
  
  <p>Please let me know what is the best way to integrate a 3rd party library into my Symfony2 projects. I would continue using it via entity, but I am getting some errors, I think the API is not working properly from entity due to come callback path errors. I could be wrong though. None the less I'd like to properly include it.</p>