SlideShare a Scribd company logo
Enterprise Persistence Layer for PHP
• Frontend web developer since 1998
• Moved to backend programming in 2002
• Currently employee of MIH – SWAT team
• Committer of many O.S. projects, including
Zend Framework, Symfony and Doctrine
• Enjoys to play Age of Empires
Doctrine is an Object Relational Modeling tool
for PHP, mostly inspired by Hibernate (Java)
and ActiveRecord (Ruby)
• Very active community
• Monthly releases
• Current work branches:
– 1.0 (LTS), 1.1, 1.2 (LTS), 2.0 (LTS)
• Integrates with many different frameworks:
– Zend Framework
– Symfony
– CodeIgniter
– Kohana
– …
• Supports all drivers supported by PDO
• Based on JSR-317 a.k.a. JPA v2.0 (~80%)
• Java…. What?!? #$&*@!
• PHP still lacks of standards
• PHP Standards Group to the rescue!
Challenges
• No need to extend base class
• New Reflection support
• Benchmarks (˜50000 iterations):
– Setter:
• $o->prop set: 0.35872411727905
• $o->setProp: 0.61513090133667 (71% slower)
• $reflProp->setValue: 0.67149507522583 (87% slower)
– Getter:
• $o->prop get: 0.25784397125244
• $o->getProp: 0.46534395217896 (80% slower)
• $reflProp->getValue: 0.64541401863098 (150% slower)
• Optimize hydration of entities
• Garbage Collector – Identity Map
• spl_object_hash
• SplObjectStorage vs. ArrayAccess
• Optimize hydration of Entities
• Benchmarks:
– Doctrine 1.1
• 4.3435637950897 for 5000 records
– Doctrine 2.0
• 1.4314442552312 for 5000 records
• 3.4690098762528 for 10000 records
• Replication support
• Internal mindset change
• No more weird DSN constructions
• No more shared Identity Maps across multiple
connections
• Huge API of public methods
• Lambdas and Closures
• Centralized entry points of methods
• No singleton nightmares!
- I have a problem!
- You can fix it with a singleton.
- Now I have 2 problems…
• RDBMS <-> PHP differences
• Clean separation of Platforms via Dialects
• Separation between DB value and PHP value
• Extendable to user land
• String processing for DQL
• Implemented a LL(*) parser
• Constructs AST nodes
• TreeWalkers to do compilation DQL -> SQL
• Cache support to prevent overhead
• Metadata Mapping
• Extendable mapping drivers
• Should not mess Entities code – VOs
• Cache support to prevent overhead
• Real Native SQL support
• Introduction of ResultsetMapping support
• Allow custom columns to be mapped into VOs
• Specific DBMS SQL supported
• Commit ordering
• True multigraph implementation
• Topological Sorting
• Prevents cycles
• F*cking incredible fast!
Almost 95% of codebase rewritten
Requires PHP 5.3
Simplified public API
Smaller footprint
Un-necessary clutter removed
No more cyclic references
Code heavily decoupled
Extremely extendable
• Three main packages:
– Common
– DBAL
– ORM
– Maybe in the future ODM…
• Anyone interested to contribute?
• Class Loaders
• Annotations support
• Collection
• Cache
• Event System
• Common LL(*) classes
• Class loaders:
– GlobalClassLoader
– IsolatedClassLoader
• Annotations EBNF – Yeah baby!
Annotation ::= "@" AnnotationName ["(" [Values] ")”]
AnnotationName ::= QualifiedName | SimpleName
QualifiedName ::= NameSpacePart "" {NameSpacePart ""}*
SimpleName
NameSpacePart ::= identifier
SimpleName ::= identifier
Values ::= Array | Value {"," Value}*
Value ::= PlainValue | FieldAssignment
PlainValue ::= integer | string | float | boolean |
Array | Annotation
FieldAssignment ::= FieldName "=" PlainValue
FieldName ::= identifier
Array ::= "{" ArrayEntry {"," ArrayEntry}* "}”
ArrayEntry ::= Value | KeyValuePair
KeyValuePair ::= Key "=" PlainValue
Key ::= string | integer
• Use DBAL independent of ORM
• Powerful Database Abstraction Layer
• Always existed, but it wasn’t advertised
• Can be a separate package in the future
• Platforms, Drivers and SchemaManagers
• Nested transactions
• Fully supports:
– Schemas
– Sequences
– Catalogs
Doctrine 2.0 Enterprise Persistence Layer for PHP
Doctrine 2.0 Enterprise Persistence Layer for PHP
• Supports:
– One-to-one
– One-to-many
– Many-to-many
• Multigraph
– Unidirectional
– Bidirectional
• Simplified bootstrap code
• Driver based Metadata
– Annotations
– PHP
– XML
– YAML
– … your own?!
Doctrine 2.0 Enterprise Persistence Layer for PHP
Doctrine 2.0 Enterprise Persistence Layer for PHP
Doctrine 2.0 Enterprise Persistence Layer for PHP
Doctrine 2.0 Enterprise Persistence Layer for PHP
• Working with objects
• Doctrine Query Language
– Similar do HQL or JPQL
– Automatically makes join restrictions
– Supports inheritance natively
– Can be boosted by usage of a Query Cache
– Easily extendable
• Querying
– DQL string
– QueryBuilder object (Criteria)
– Native SQL query
Doctrine 2.0 Enterprise Persistence Layer for PHP
Doctrine 2.0 Enterprise Persistence Layer for PHP
Doctrine 2.0 Enterprise Persistence Layer for PHP
• Directed Acyclic Graphs
• Easily extendable
• Several handy tasks to help development
– Schema-tool
– Generate-proxies
– Convert-mapping
– Run-sql
– Run-dql
Doctrine 2.0 Enterprise Persistence Layer for PHP
Doctrine 2.0 Enterprise Persistence Layer for PHP
Guilherme Blanco
guilhermeblanco gmail com
+55 16 9215.8480
http://www.doctrine-project.org

More Related Content

PDF
PHP7 is coming
PDF
Understanding PHP objects
PPTX
Zephir - A Wind of Change for writing PHP extensions
ODP
Php in 2013 (Web-5 2013 conference)
ODP
PHP5.5 is Here
PPTX
PHP7 Presentation
PDF
Introduction to clojure
PDF
PECL Picks - Extensions to make your life better
PHP7 is coming
Understanding PHP objects
Zephir - A Wind of Change for writing PHP extensions
Php in 2013 (Web-5 2013 conference)
PHP5.5 is Here
PHP7 Presentation
Introduction to clojure
PECL Picks - Extensions to make your life better

What's hot (20)

PPTX
Php on the Web and Desktop
PDF
The worst Ruby codes I’ve seen in my life - RubyKaigi 2015
PDF
Building Custom PHP Extensions
PPTX
PHP 7 Crash Course - php[world] 2015
PDF
PHP traits, treat or threat?
PPTX
PHP from soup to nuts Course Deck
PDF
PHP Enums - PHPCon Japan 2021
PDF
Diving into HHVM Extensions (PHPNW Conference 2015)
PDF
PHP 8.1 - What's new and changed
PPT
The Php Life Cycle
PDF
Typed Properties and more: What's coming in PHP 7.4?
PDF
SPL to the Rescue - Tek 09
PPTX
Php on the desktop and php gtk2
PDF
Spl in the wild
ODP
The why and how of moving to PHP 5.4/5.5
PDF
Preparing for the next PHP version (5.6)
PDF
PHP 良好實踐 (Best Practice)
PDF
PHP7 - The New Engine for old good train
KEY
Alfresco the clojure way
Php on the Web and Desktop
The worst Ruby codes I’ve seen in my life - RubyKaigi 2015
Building Custom PHP Extensions
PHP 7 Crash Course - php[world] 2015
PHP traits, treat or threat?
PHP from soup to nuts Course Deck
PHP Enums - PHPCon Japan 2021
Diving into HHVM Extensions (PHPNW Conference 2015)
PHP 8.1 - What's new and changed
The Php Life Cycle
Typed Properties and more: What's coming in PHP 7.4?
SPL to the Rescue - Tek 09
Php on the desktop and php gtk2
Spl in the wild
The why and how of moving to PHP 5.4/5.5
Preparing for the next PHP version (5.6)
PHP 良好實踐 (Best Practice)
PHP7 - The New Engine for old good train
Alfresco the clojure way
Ad

Similar to Doctrine 2.0 Enterprise Persistence Layer for PHP (20)

PDF
ZendCon2010 The Doctrine Project
KEY
Object Relational Mapping in PHP
PDF
Zend Framework 1 + Doctrine 2
ODP
Achieve the norm with Idiorm
PDF
Doctrine2 enterpice
PDF
Doctrine 2 - Enterprise Persistence Layer For PHP
PDF
Doctrine2
PDF
Doctrine for NoSQL
PDF
Doctrine and NoSQL
PDF
Doctrine with Symfony - SymfonyCon 2019
PDF
Introduction To Doctrine 2
PDF
Doctrine Project
PDF
ITB2017 - Slaying the ORM dragons with cborm
PPTX
PHP, The X DevAPI, and the MySQL Document Store -- Benelux PHP Confernece 2019
PPTX
PHP, The X DevAPI, and the MySQL Document Store Presented January 23rd, 20...
PDF
Doctrine Php Object Relational Mapper
PDF
Libertyvasion2010
PDF
DPC2007 PDO (Lukas Kahwe Smith)
 
PDF
ElePHPant7 - Introduction to PHP7
ZendCon2010 The Doctrine Project
Object Relational Mapping in PHP
Zend Framework 1 + Doctrine 2
Achieve the norm with Idiorm
Doctrine2 enterpice
Doctrine 2 - Enterprise Persistence Layer For PHP
Doctrine2
Doctrine for NoSQL
Doctrine and NoSQL
Doctrine with Symfony - SymfonyCon 2019
Introduction To Doctrine 2
Doctrine Project
ITB2017 - Slaying the ORM dragons with cborm
PHP, The X DevAPI, and the MySQL Document Store -- Benelux PHP Confernece 2019
PHP, The X DevAPI, and the MySQL Document Store Presented January 23rd, 20...
Doctrine Php Object Relational Mapper
Libertyvasion2010
DPC2007 PDO (Lukas Kahwe Smith)
 
ElePHPant7 - Introduction to PHP7
Ad

More from Guilherme Blanco (14)

PDF
Enterprise php
PDF
PHP for Adults: Clean Code and Object Calisthenics
PDF
PHP para Adultos: Clean Code e Object Calisthenics
PDF
ORM dont kill your DB, developers do
KEY
Object Calisthenics Applied to PHP
KEY
PHPubSP Object Calisthenics aplicado ao PHP
ODP
Javascript para adultos
ODP
Dependency injection
PDF
Doctrine2 Seminário PHP
PDF
IPC2010SE Doctrine2 Enterprise Persistence Layer for PHP
KEY
Doctrine 2.0: A evolução da persistência em PHP
KEY
PHP, Daemons e Multimedia
PPT
Desenvolvimento Agil Com Doctrine Orm
Enterprise php
PHP for Adults: Clean Code and Object Calisthenics
PHP para Adultos: Clean Code e Object Calisthenics
ORM dont kill your DB, developers do
Object Calisthenics Applied to PHP
PHPubSP Object Calisthenics aplicado ao PHP
Javascript para adultos
Dependency injection
Doctrine2 Seminário PHP
IPC2010SE Doctrine2 Enterprise Persistence Layer for PHP
Doctrine 2.0: A evolução da persistência em PHP
PHP, Daemons e Multimedia
Desenvolvimento Agil Com Doctrine Orm

Recently uploaded (20)

DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Approach and Philosophy of On baking technology
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Empathic Computing: Creating Shared Understanding
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
The AUB Centre for AI in Media Proposal.docx
Understanding_Digital_Forensics_Presentation.pptx
Digital-Transformation-Roadmap-for-Companies.pptx
Approach and Philosophy of On baking technology
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Unlocking AI with Model Context Protocol (MCP)
MYSQL Presentation for SQL database connectivity
Spectral efficient network and resource selection model in 5G networks
Programs and apps: productivity, graphics, security and other tools
Empathic Computing: Creating Shared Understanding
sap open course for s4hana steps from ECC to s4
Advanced methodologies resolving dimensionality complications for autism neur...
Per capita expenditure prediction using model stacking based on satellite ima...
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Network Security Unit 5.pdf for BCA BBA.
Profit Center Accounting in SAP S/4HANA, S4F28 Col11

Doctrine 2.0 Enterprise Persistence Layer for PHP

  • 2. • Frontend web developer since 1998 • Moved to backend programming in 2002 • Currently employee of MIH – SWAT team • Committer of many O.S. projects, including Zend Framework, Symfony and Doctrine • Enjoys to play Age of Empires
  • 3. Doctrine is an Object Relational Modeling tool for PHP, mostly inspired by Hibernate (Java) and ActiveRecord (Ruby)
  • 4. • Very active community • Monthly releases • Current work branches: – 1.0 (LTS), 1.1, 1.2 (LTS), 2.0 (LTS)
  • 5. • Integrates with many different frameworks: – Zend Framework – Symfony – CodeIgniter – Kohana – … • Supports all drivers supported by PDO
  • 6. • Based on JSR-317 a.k.a. JPA v2.0 (~80%) • Java…. What?!? #$&*@! • PHP still lacks of standards • PHP Standards Group to the rescue!
  • 8. • No need to extend base class • New Reflection support • Benchmarks (˜50000 iterations): – Setter: • $o->prop set: 0.35872411727905 • $o->setProp: 0.61513090133667 (71% slower) • $reflProp->setValue: 0.67149507522583 (87% slower) – Getter: • $o->prop get: 0.25784397125244 • $o->getProp: 0.46534395217896 (80% slower) • $reflProp->getValue: 0.64541401863098 (150% slower)
  • 9. • Optimize hydration of entities • Garbage Collector – Identity Map • spl_object_hash • SplObjectStorage vs. ArrayAccess
  • 10. • Optimize hydration of Entities • Benchmarks: – Doctrine 1.1 • 4.3435637950897 for 5000 records – Doctrine 2.0 • 1.4314442552312 for 5000 records • 3.4690098762528 for 10000 records
  • 11. • Replication support • Internal mindset change • No more weird DSN constructions • No more shared Identity Maps across multiple connections
  • 12. • Huge API of public methods • Lambdas and Closures • Centralized entry points of methods • No singleton nightmares! - I have a problem! - You can fix it with a singleton. - Now I have 2 problems…
  • 13. • RDBMS <-> PHP differences • Clean separation of Platforms via Dialects • Separation between DB value and PHP value • Extendable to user land
  • 14. • String processing for DQL • Implemented a LL(*) parser • Constructs AST nodes • TreeWalkers to do compilation DQL -> SQL • Cache support to prevent overhead
  • 15. • Metadata Mapping • Extendable mapping drivers • Should not mess Entities code – VOs • Cache support to prevent overhead
  • 16. • Real Native SQL support • Introduction of ResultsetMapping support • Allow custom columns to be mapped into VOs • Specific DBMS SQL supported
  • 17. • Commit ordering • True multigraph implementation • Topological Sorting • Prevents cycles • F*cking incredible fast!
  • 18. Almost 95% of codebase rewritten Requires PHP 5.3
  • 20. Un-necessary clutter removed No more cyclic references
  • 22. • Three main packages: – Common – DBAL – ORM – Maybe in the future ODM… • Anyone interested to contribute?
  • 23. • Class Loaders • Annotations support • Collection • Cache • Event System • Common LL(*) classes
  • 24. • Class loaders: – GlobalClassLoader – IsolatedClassLoader
  • 25. • Annotations EBNF – Yeah baby! Annotation ::= "@" AnnotationName ["(" [Values] ")”] AnnotationName ::= QualifiedName | SimpleName QualifiedName ::= NameSpacePart "" {NameSpacePart ""}* SimpleName NameSpacePart ::= identifier SimpleName ::= identifier Values ::= Array | Value {"," Value}* Value ::= PlainValue | FieldAssignment PlainValue ::= integer | string | float | boolean | Array | Annotation FieldAssignment ::= FieldName "=" PlainValue FieldName ::= identifier Array ::= "{" ArrayEntry {"," ArrayEntry}* "}” ArrayEntry ::= Value | KeyValuePair KeyValuePair ::= Key "=" PlainValue Key ::= string | integer
  • 26. • Use DBAL independent of ORM • Powerful Database Abstraction Layer • Always existed, but it wasn’t advertised • Can be a separate package in the future
  • 27. • Platforms, Drivers and SchemaManagers • Nested transactions • Fully supports: – Schemas – Sequences – Catalogs
  • 30. • Supports: – One-to-one – One-to-many – Many-to-many • Multigraph – Unidirectional – Bidirectional
  • 32. • Driver based Metadata – Annotations – PHP – XML – YAML – … your own?!
  • 37. • Working with objects
  • 38. • Doctrine Query Language – Similar do HQL or JPQL – Automatically makes join restrictions – Supports inheritance natively – Can be boosted by usage of a Query Cache – Easily extendable
  • 39. • Querying – DQL string – QueryBuilder object (Criteria) – Native SQL query
  • 43. • Directed Acyclic Graphs • Easily extendable • Several handy tasks to help development – Schema-tool – Generate-proxies – Convert-mapping – Run-sql – Run-dql
  • 46. Guilherme Blanco guilhermeblanco gmail com +55 16 9215.8480 http://www.doctrine-project.org

Editor's Notes

  • #4: Project started in 2005/2006 by Konsta Currently maintained by Jonathan Wage, Roman Borschel and Guilherme Blanco
  • #5: Active community: IRC, Mailing List, Cookbook, etc 1.0 LTS (support ends in March 2010) 1.1 (supports ends in November 2009) 1.2 LTS (support ends in March 2011) 2.0 LTS (support ends in March 2011)
  • #7: Doctrine team follows all functional specs Wants to contribute to PHP Standards Group
  • #9: Optimize Reflection even more!
  • #11: Hydration start/end: memory remains almost the same amount (thanks to GC!)
  • #12: EntityManagers for the rescue! Sharding in the future? Maybe in 2.X!
  • #14: Dialects reuse methods of Platforms SchemaManagers are responsible for complex tasks (CREATE TABLE, INDEX, UPDATE TABLE, etc)
  • #15: Top-down recursive descent parser AST class names follows EBNF grammar rules Reuses Platform to support SQL differences
  • #16: Annotations support is a LL(*) parser too =D
  • #18: OTHER STUFF!!! CLI Tasks - DAGs to control options dependencies and exclusions TBF! Reverse engineering (DB -> VOs + Mappings) Mapping conversion between drivers Schema Generation Tool (create, drop & update) Proxy Objects (for Lazy-Loading) Event System Centralized Configuration Multi-level Caching support (APC, Memcache, Xcache)
  • #31: Self referencing, one-to-one, one-to-many, many-to-many Owning side and inverse side. Owning side determines updates to Database
  • #39: DQL: Looks like SQL, but it isn’t! Supports SELECT, UPDATE and DELETE
  • #40: Criteria: Fluent vs. Programmatically API