SlideShare a Scribd company logo
ŹleużywaszDoctrine’a!
1
ŹLE UŻYWASZ DOCTRINE’A !
PUŁAPKI W KTÓRE ZBYT CZĘSTO DAJEMY SIĘ ZŁAPAĆ
ŹleużywaszDoctrine’a!
2
CO TO DOCTRINE ?
TOMASZ `SURO` SUROWIEC
DEVELOPER AT
ŹleużywaszDoctrine’a!
4
ENCJE
ExceptionDesign
5
Źle używasz Doctrine’a!
Z PALCA DODAMY JESZCZE JAKIEŚ RELACJE
ŹleużywaszDoctrine’a!
7
POROZMAWIAJMY O ID
ŹleużywaszDoctrine’a!
8
Dostępny dopiero po flush’u
Encja nie jest “walidna”
Nie nadaje się do URL’a
Kusi żeby użyć go do sortowania
Nasz obiekt nie działa bez bazy danych
ID GENEROWANE AUTOMATYCZNIE
ŹleużywaszDoctrine’a!
9
ALTERNATYWY ?
COMPOSER REQUIRE RAMSEY/UUID
ŹleużywaszDoctrine’a!
10
UUID
Źle używasz Doctrine’a!
ZRÓB SOBIE SAM UNIKALNE ID
64^6 = 68 719 476 736
hqme40, A4jd9s
gOapcY, a-aJ92
ZlWVeS, Ydk_3k
ŹleużywaszDoctrine’a!
12
YOUTUBE UŻYWA CZEGOŚ PODOBNEGO
https://www.youtube.com/watch?v=gocwRvLhDf8
Źle używasz Doctrine’a!
WRÓĆMY DO NASZEGO MODELU
ŹleużywaszDoctrine’a!
14
CZAS NA WŁAŚCIWOŚCI
ŹleużywaszDoctrine’a!
15
A MOŻE BY TAK ?
Źle używasz Doctrine’a!
JEST LEPIEJ, ALE …
…OBIEKTU NIE PODEPNIEMY POD FORM
I DOBRZE !!!
PODEPNIJMY TAM DTO
Źle używasz Doctrine’a!
STWORZYĆ OBIEKT MOŻEMY TAK
ŹleużywaszDoctrine’a!
18
RELACJE
Źle używasz Doctrine’a!
UNIKAJMY RELACJI DWUSTRONNYCH
ŹleużywaszDoctrine’a!
20
CZASAMI BĄDŹMY ZACHŁANNI
Źle używasz Doctrine’a!
NIE WSZYSTKO MUSI BYĆ ENCJĄ
Źle używasz Doctrine’a!
CZASAMI
WYSTARCZY
VALUE
OBJECT
Źle używasz Doctrine’a!
Źle używasz Doctrine’a!
CO W PRZYPADKU CZEGOŚ CZEGO
OBIEKT OSADZONY NIE OGARNIE ?
CUSTOM TYPE !
Źle używasz Doctrine’a!
Źle używasz Doctrine’a!
Źle używasz Doctrine’a!
ŹleużywaszDoctrine’a!
28
REPOZYTORIA
Źle używasz Doctrine’a!
REPOZYTORIUM JEST SERWISEM
Źle używasz Doctrine’a!
Źle używasz Doctrine’a!
NIE UŻYWAJ
GET MANAGER -> GET REPOSITORY
Źle używasz Doctrine’a!
FIND ALL() ?
ŹleużywaszDoctrine’a!
33
Źle używasz Doctrine’a!
SIŁA I UŁOMNOŚĆ
CUSTOMOWYCH REPO
ŹleużywaszDoctrine’a!
35
ŹleużywaszDoctrine’a!
36
ŹleużywaszDoctrine’a!
37
Źle używasz Doctrine’a!
DOPIERO SIĘ ROZKRĘCAM…
ŹleużywaszDoctrine’a!
39
Źle używasz Doctrine’a!
SZALEŃSTWO
REFAKTOR
BAJZEL
Źle używasz Doctrine’a!
QUERY FUNCTIONS !
ŹleużywaszDoctrine’a!
42
ŹleużywaszDoctrine’a!
43
BLE …
ŹleużywaszDoctrine’a!
44
Źle używasz Doctrine’a!
MAŁY BONUSIK
Źle używasz Doctrine’a!
CO Z DRY ?
ŹleużywaszDoctrine’a!
47
ŹleużywaszDoctrine’a!
48
ŹleużywaszDoctrine’a!
49
KONIECZNIE ZAJRZYJCIE NA:
https://ocramius.github.io/doctrine-best-practices/#/
ŹleużywaszDoctrine’a!
50
DZIĘKI …

More Related Content

Featured

Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
Christy Abraham Joy
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
Vit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
MindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
GetSmarter
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
Alireza Esmikhani
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
Project for Public Spaces & National Center for Biking and Walking
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
Erica Santiago
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Saba Software
 

Featured (20)

Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
 

Zle Używasz Doctrine'a