I’m new to Symfony2 and I have faced some simple problem but I’m not sure how to manage with it. I need to use one simple 3rd party class and I’m not sure where and how to store it in project structure. Should I store is a Service in my Bundle or maybe I should store it in vendors directory? And if I’ll store it in vendors isn’t it a bad practice to store there the libs that isn’t Symfony supported vendors?
Share
Usually you include those in your project with Composer. I suggest you to take a look at packagist to look if there is a Composer package for your class, otherwise you can’t require it with composer.
Composer puts your classes in the
vendordirectory, you should put all ‘vendors’ (3th party libraries) there. Take a look on where to put them in that directory, so that the Composer autoloader can autoload it.After that, it is recommend to create a bundle for that specific class. It is a best practise to create a service there. For instance, if your class is
Fooyou create aAcme\FooBundlewhich loads theFooservice: