Symfonian在Symfony 2中存储自定义实用程序和助手的方式 [英] Symfonian way to store custom utilities and helpers in symfony 2

查看:334
本文介绍了Symfonian在Symfony 2中存储自定义实用程序和助手的方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时候我会写一些函数或过程作为助手和实用程序,以在我的所有应用程序中使用...现在我开始使用Symfony 2,我不知道根据symfony的最佳方法是什么2 Bundles的哲学...我不想创建一个整个Bundle只是为了存储一些功能,但是如果这是我做的最好方法.谢谢!

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!

推荐答案

如果您的实用程序和助手不是特定于Symfony的,请在单独的存储库中创建一个库,然后使用depsbin/vendors install命令将其安装到供应商或通过作曲家,这将成为自Symfony 2.1以来管理供应商的默认方式.

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.

如果您希望库与Symfony无缝集成,请在另一个单独的存储库中创建一个包,然后将其安装到供应商.这样,您的库可以在Symfony项目之外使用,但在Symfony项目中使用时会提供一些便利.

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.

也看到了一个相关的问题.

这篇关于Symfonian在Symfony 2中存储自定义实用程序和助手的方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆