Symfony 2 - library library integration
I'm all about symfony 2 best practice and I would like to integrate a php library into a project. A library is not a bundle, a simple php class with some methods.
My question follows below which does NOT have an accepted answer. Anyway, from what I read here, I decided to autoload the class, but have no idea where I should find the php file.
Maybe src/MyBundle/DependencyInjection/
      
        
        
        
      
    ? I really doubt it, because the library has no dependency on other services I have.
Should I create a directory like src/MyBundle/Services/
      
        
        
        
      
    or src/MyBundle/Libraries/
      
        
        
        
      
    ?
What's the best practice here?
as stated by b.enoit.be create service from class.
MyBundle / Services / MyServiceClass.php
<?php
namespace MyBundle\Service;
class MyService
{
...
}
      
        
        
        
      
    
app / Config/services.yml
services:
    app.my_service:
        class: MyBundle\Service\MyService
      
        
        
        
      
    
use it for example. in the controller
MyBundle / controller / DefaultController.php
<?php
namespace MyBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
class DefaultController extends Controller
{
    public function indexAction(Request $request)
    {
        ...
        // get the service from the container
        $yourService = $this->get('app.my_service');
        ...
    }
}
?>