在使用Symfony2之前,我曾经有一个包含许多简单但有用的函数的公共库(例如,一个函数在参数中使用“Azè_rtï”并返回“aze-rti”)。
所以,好吧,我创建了一个Bundle:CommonLibsBundle。
但是..我只有一两个php文件。在这种情况下使用控制器/视图/模型对我没有意义。 我该怎么办?我可以删除新包中的所有文件夹(Controller,DependencyInjection,Resources,Tests ... + CommonLibsBundle.php),然后将我的lib.php放入其中吗?
非常感谢, 布利斯
答案 0 :(得分:0)
Unless you need to tap into the Symfony framework itself - for configuration or to define services, it doesn't need to be a bundle - it's just a library. Give it a reasonable namespace, and call as required as you would any other component or library.
Even if you wanted to add Symfony-specific services that you could call, there is something to be said to still have an external simple library - usable anywhere, which then is wrapped by a very thin bundle which would only add the Symfony-specific (or Laravel, or ZF, or whatever) services and configuration as required.