使用 Doctrine for PHP 的优势? [英] Advantages of using Doctrine for PHP?

查看:24
本文介绍了使用 Doctrine for PHP 的优势?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

刚刚遇到了 Doctrine 项目,它有一个对象关系映射器和一个数据库抽象层.Doctrine 提供了哪些其他 PHP 抽象层没有提供的功能?除了通过使用 Doctrine 查询语言编写的查询获取对象之外,您还可以将 ORM 用于什么实际用途?查询语言真的是您想要用来开发整个 Web 应用程序的语言吗?性能好吗?

总体而言,在 Doctrine 上构建应用程序是否更易于维护和理解?它是否过度设计,是否建立在适合中小型项目的抽象层上?(<50 个 GUI 屏幕),而不是直接使用 MySQL.

解决方案

Doctrine 提供了哪些其他 PHP 抽象层没有提供的功能?

  1. 实现 DataMapper 模式而不是 ActiveRecord.
  2. 支持注释、XML 和用于架构的 YAML.
  3. 使用 DQL.
  4. 利用 PHP 5.3+ 的优势.
  5. 速度快,社区庞大.
  6. 除了 ORM,还有 ODM.

<块引用>

查询语言真的是您想用来开发整个网络应用程序的语言吗?

负责维护业务对象的应用程序的一部分应该知道 Doctrine 的存在.而那部分不一定是 100% 基于 Doctrine 的.

<块引用>

总体而言,在 Doctrine 上构建应用是否更易于维护和理解?

肯定的.代码更易于阅读、理解和维护.

<块引用>

是否过度设计,对于中小型项目是否合理?

实际上,Doctrine 的基本原理非常简单.对于小型、中型甚至一些大型应用程序来说,它是一个非常好的选择.

<小时>

教义不是万能的,有时会有点问题.然而,对于典型的任务,它非常有用.恕我直言,这是目前 PHP 最好的 ORM/ODM.

Just came across the Doctrine Project which has an Object Relational Mapper and a DB Abstraction Layer. What does Doctrine provide that other PHP abstraction layers don't? And what practical use can you put the ORM to, apart from fetching objects via queries written in Doctrine Query Language? Is the query language really something you want to develop an entire web app in? Does it perform well?

On the whole does building an app on Doctrine make it easier to maintain and understand? Is it over-engineered, and is building on an abstraction layer sensible for small-medium size projects? (<50 GUI screens), as opposed to directly working with MySQL.

解决方案

What does Doctrine provide that other PHP abstraction layers don't?

  1. Implements DataMapper pattern rather ActiveRecord.
  2. Supports annotations, XML and YAML for schema.
  3. Uses DQL.
  4. Uses benefits of PHP 5.3+.
  5. Is fast and has large community.
  6. Except ORM there is ODM.

Is the query language really something you want to develop an entire web app in?

Just a part of the application responsible for maintaining business-objects should be aware of the existence of Doctrine. And that part doesn't have to be 100% Doctrine-based.

On the whole does building an app on Doctrine make it easier to maintain and understand?

Definitely. The code is easier to read, understand and maintain.

Is it over-engineered, and is it sensible for small-medium size projects?

Actually Doctrine is quite simple in its fundamentals. And it's a very good choice for small, medium and even some large applications.


Doctrine isn't the answer for everything and sometimes it's a little problematic. However for typical tasks it's extremely useful. IMHO the best ORM/ODM for PHP at this moment.

这篇关于使用 Doctrine for PHP 的优势?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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