Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfonian way to store custom utilities and helpers in symfony 2

Sometimes there are some functions or procedures that I write as helpers and utilities to use all across my apps... Now I'm starting to use Symfony 2, and I don't know what is the best way according to symfony 2 philosophy of Bundles... I wouldn't like to have to create a whole Bundle just to store maybe a couple of functions, but if it is the best way I'll do it. Thanks!

like image 590
Throoze Avatar asked Apr 10 '12 06:04

Throoze


1 Answers

If your utilities and helpers are not Symfony specific, create a library in a separate repo and install it to vendors using the deps with the bin/vendors install command or via Composer, which will become the default way of managing vendors since Symfony 2.1.

If you want your library to integrate seamlessly with Symfony, create a bundle in another separate repo and install it to vendors. This way your library could be used outside Symfony projects, but provide some conveniences when used in Symfony ones.

Also see a somewhat related question.

like image 152
Elnur Abdurrakhimov Avatar answered Sep 28 '22 02:09

Elnur Abdurrakhimov