Symfony业务逻辑 [英] Symfony business logic

查看:66
本文介绍了Symfony业务逻辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在symfony中,我看到一些编码器将业务逻辑放入动作中(即控制器),而一些编码器将其放入模型中(Doctrine).在控制器或模型中,业务逻辑应属于什么地方?如果我不使用Doctrine,而只是纯文本文件怎么办?

In symfony, I see some coders put business logic in the actions ( controllers that is ), and some coders put it in the models ( Doctrine ). Where should the business logic belong, in the controller or model? What if I didn't use Doctrine, and it was just plain text files?

推荐答案

在控制器中放置业务逻辑是一个糟糕的习惯,模型是它的基础.

Put the business logic in the controller is a bad pratice, the model is home for it.

如果没有教义,您仍然可以拥有自己的实体,模型类(应该).您的文件可以被抽象,然后将其业务逻辑放在自己的类中,而不是在控制器中.

If you don't have Doctrine, you can still have entities, model classes of your own (you should). Your files can be abstracted, and then put their business logic in their own classes, not in the controller.

关于MVC的一切,M完全取决于您.

It's all about MVC, and the M is really up to you.

这篇关于Symfony业务逻辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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