SYMFONY仅为Datatype C Like struct创建全局类
我目前正在Symfony 6.1开发一个应用程序。 我总是有一组相同的数据,该数据始终使用相同的格式。为此,我想创建一个类,该类使用此结构生成对象。 该课程应在全球上可用(例如Symfony服务),但允许创建我想要的尽可能多的实例。据我所知,Symfony Services仅在自动化时创建一个实例。 在不弄乱预期的同伴风格的情况下,在Symfony中做到这一点的最佳方法是什么?
class MyDatatype {
public $foo;
public $bar;
}
I am currently developing an APP in Symfony 6.1.
I have a always same Set of data, which is using always the same format. For this I want to create a class, which generates Objects using this structure.
This class should be globally available (like a Symfony Service) but allow to create as many Instances as I want to. Symfony Services as far as I know, only create one Instance while Autowiring.
What is the best way to do this in Symfony, without messing with the intended Symfony style?
class MyDatatype {
public $foo;
public $bar;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论