Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
WebApp development with Doctrine
Search
Radosław Zagórski
April 26, 2018
Programming
40
0
Share
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
40
Introducing to REST with Symfony 3
rzagorski
0
130
Other Decks in Programming
See All in Programming
Lemonade + Foundry Toolkit でお手軽アプリ開発
seosoft
1
270
セキュリティの専門家じゃなくてもできる。「セキュリティ意識」をアップデートして サプライチェーン攻撃への耐性を高めよう。
tk3fftk
5
590
tsserverとは何だったのか、これからどうなるのか
nowaki28
1
440
AIチームを指揮するOSS「TAKT」活用術 / How to Use “TAKT,” an OSS Tool for Orchestrating AI Teams
nrslib
6
800
IBM Bobを活用したレガシーアプリの最新化
oniak3ibm
PRO
1
160
決定論的オーケストレーションの設計と実装 / Design and Implementation of Deterministic Orchestration
nrslib
3
910
Spec-Driven Development with AI-Agents: From High-Level Requirements to Working Software
antonarhipov
2
440
メソッドのジェネリクスでGoの夢は広がるか? / Kyoto.go #65
utgwkk
3
450
SPMマルチモジュールで テストカバレッジを取得する技法
yosshi4486
0
140
OSもどきOS
arkw
0
400
DynamoDBには集計系のクエリがないけどなんとかしたい
musan
1
130
脅威をエンジニアリングの糧にして――現場編 / Turning Threats into Engineering Fuel — Field Edition
nrslib
0
240
Featured
See All Featured
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
Tell your own story through comics
letsgokoyo
1
940
How to train your dragon (web standard)
notwaldorf
97
6.7k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.8k
Art, The Web, and Tiny UX
lynnandtonic
304
22k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
300
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
55k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
350
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
560
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
62
54k
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!