Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
WebApp development with Doctrine
Search
Radosław Zagórski
April 26, 2018
Programming
40
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
WebApp development with Doctrine
WebApp development with Doctrine
Radosław Zagórski
April 26, 2018
More Decks by Radosław Zagórski
See All by Radosław Zagórski
Queuing in PHP
rzagorski
0
41
Introducing to REST with Symfony 3
rzagorski
0
140
Other Decks in Programming
See All in Programming
カツオ、ご期待ください
suneo3476
0
190
ChromeでローカルLLM
ryu1013
0
140
Herb in Rails 8.2: Your ERB views, now HTML-aware @ Rails World 2026, Austin, Texas
marcoroth
0
220
見えないものを探る要求要件定義に必要な基本的思考 / invisible-requirement-thinking
minodriven
15
8.5k
コードレビューのボトルネックを"する側"と"される側"の両面から解消する
yub0n
2
1.6k
Agentic Software Factoryに、すごく賢いIF文を。 / super smart IF statement into the Agentic Software Factory.
rkaga
8
2.2k
contenteditable と日本語入力に向き合う
colorful12
0
200
re:Inventに行く前に知っておきたい現地参加のノウハウ
nokomoro3
0
430
残高管理から台帳サービスへの進化
artoy
1
200
sbt 2.0: takeoff
eed3si9n
0
160
[JA] Domain Modeling with Vanilla Rails: 「操作」から再考するRailsの設計論
yasaichi
1
300
全ての永続トークンを、生まれる前に消し去りたい!
sylph01
2
930
Featured
See All Featured
Amusing Abliteration
ianozsvald
1
350
Producing Creativity
orderedlist
PRO
348
41k
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
How to train your dragon (web standard)
notwaldorf
96
6.9k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
460
Balancing Empowerment & Direction
lara
6
1.3k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
320
What the history of the web can teach us about the future of AI
inesmontani
PRO
2
740
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
560
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.6k
How STYLIGHT went responsive
nonsquared
100
6.3k
Marketing to machines
jonoalderson
1
5.9k
Transcript
Radosław Zagórski www.linkedin.com/in/radoslawzagorski
WebApp development with doctrine
What is Doctrine? A group of persistence-oriented libraries for PHP
Doctrine Project • Common • Annotations • Cache • Collections
• Lexer • Migrations • MongoDB Abstraction Layer • MongoDB Object Document Mapper • PHPCR ODM • Inflector • Object Relational Mapper • Database Abstraction Layer (DBAL)
Inflector
Database Abstraction Layer (DBAL)
Database Abstraction Layer (DBAL)
Database Abstraction Layer (DBAL)
Database Abstraction Layer (DBAL)
Object Relational Mapper
Object Relational Mapper
KNOW YOUR TOOLS https://www.doctrine-project.org/projects.html
What is Doctrine ORM for? • OLTP - Online Transaction
Processing • DDD • Fast prototyping • Object Oriented at first
What is Doctrine ORM not for? • Dynamic data structures
• Reporting • Statistics
entities should work without the ORM entities should work without
the DB
the database is just saving things
design entities first define mappings after designing the entities define
the database after modeling you domain
None
entities are not typed arrays
entities have behaviour
None
remember about the LOD
None
None
More expressive Easier to test Less coupling More flexible Easier
to refactor
disallow collection access from outside the entity
None
keep collection hidden in you entities
None
entities should always be valid invalid state should be in
a different object (use DTO)
None
avoid setters
don’t use lifecycle callbacks
avoid coupling with the application layer
None
form components break entity validity
avoid auto-generated identifiers
Avoid auto-generated identifiers your db operations will block each other
you are denying bulk inserts you cannot make multi-request transactions your object is invalid until saved your object does not work without the DB
ramsey/uuid
AUTO_INCREMENT IS ABUSED FOR SORTING Are you looking for a
DATETIME field instead?
favour immutable entities
None
Immutable data is simple Immutable data is cacheable (forever) Immutable
data is predictable Immutable data enables historical analysis
You may want to look at Event Sourcing… (https://github.com/prooph/event-sourcing)
avoid soft-deletes
Soft Deletes come from an era where keeping everything in
a single DB was required
break data integrity break immutability break validity
Annotations? XML? YAML? Mapping Driver
Lazy Loading or Eager Loading? Extra Lazy Loading?
use custom repositories
None
query functions are better
None
Separate MyRepository#get() and MyRepository#find()
MyRepository#find() can return null MyRepository#get() cannot return null
None
using a get() method that throws, you can simplify error
logic
DO NOT NORMALIZE DB WITHOUT A NEED FOR IT
CONSIDER USING SEPARATE DBS Transactional Data != Reporting
Data
doctrine paginator isn’t perfect
None
choosing Doctrine does not require you to go all in
you can implement 80% of your use cases with Doctrine
in a sane way.
None
Thank you!