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
Usnadněte si soužití s Doctrine
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Filip Procházka
October 27, 2013
Technology
37
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Usnadněte si soužití s Doctrine
Filip Procházka
October 27, 2013
More Decks by Filip Procházka
See All by Filip Procházka
Evolving architecture
fprochazka
0
250
Value objects in PHP
fprochazka
1
240
Jak psát testy na REST API
fprochazka
0
120
V gitu se nic neztratí
fprochazka
0
410
Co se PHP programátor může naučit od Javy?
fprochazka
1
150
4 roky remote
fprochazka
1
91
Před čím tě Nette ani Symfony neochrání
fprochazka
0
160
Nejlepší cache je žádná cache
fprochazka
0
130
Doctrine: co dělat, když entity nestačí
fprochazka
0
82
Other Decks in Technology
See All in Technology
新しいUbuntu/GNOMEが使いたいからXからWaylandへ移行頑張ってるの巻 2026-06-20
nobutomurata
0
140
SONiCの統計情報を取得したい
sonic
0
200
LLMにもCAP定理があるという話
harukasakihara
0
400
MCP Appsを作ってみよう
iwamot
PRO
4
680
手塩にかけりゃいいってもんじゃない
ming_ayami
0
600
作って終わりにしない タイミーのセマンティックレイヤー育成の現在地
chanyou0311
4
2.4k
【Cyber-sec+】経営層を"動かす"ための考え方
hssh2_bin
0
190
Agent Skills設計で柔軟性と硬さのバランスが難しい話
nassy20
0
140
データサイエンスを価値につなげるプロジェクト設計 〜 DS一年目が現場で得た気づき 〜
ysd113
1
270
気軽に使える"情報のハブ"としてのNotion活用 〜フロー情報の集積点 と、 Claude Code × Notion AI〜
syucream
1
150
iAEONの段階的リアーキテクト戦略 / iAEON's_Gradual_Re-architecture_Strategy
aeonpeople
0
220
自宅LLMの話
jacopen
1
610
Featured
See All Featured
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
390
Designing Experiences People Love
moore
143
24k
What's in a price? How to price your products and services
michaelherold
247
13k
Into the Great Unknown - MozCon
thekraken
41
2.6k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
Technical Leadership for Architectural Decision Making
baasie
3
410
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
250
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
140
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
2k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
Transcript
Usnadněte si soužití s Doctrine Filip Procházka
Co si ukážeme? + Kdyby/Doctrine + Kdyby/Console + Kdyby/Events
Proč Kdyby? - Doctrine má spoustu skvělých vlastností - Doctrine
má spoustu otravných vlastností - Kdyby je plug&play (convention over configuration), tedy konfigurace na pár řádků a hned můžete pracovat
Instalace $ composer require \ kdyby/doctrine $ composer create-project \
hosiplan/project
Konfigurace extensions: annotations: Kdyby\Annotations\DI\AnnotationsExtension console: Kdyby\Console\DI\ConsoleExtension events: Kdyby\Events\DI\EventsExtension doctrine: Kdyby\Doctrine\DI\OrmExtension
Konfigurace doctrine: user: foo password: bar dbname: sandbox metadata: App:
%appDir%
Entita use Doctrine\ORM\Mapping as ORM; /** @ORM\Entity() */ class Article
extends \Kdyby\Doctrine\Entities\IdentifiedEntity { /** @ORM\Column(type="string") */ protected $title; }
BaseEntity? Ta je přece fuj! class Article extends BaseEntity {
private $one; protected $two; public $three; }
Skvělé na prototypování $article->getOne(); $article->one; $article->getTwo(); $article->two; $article->getThree(); $article->three; $article->addComment($comment);
$article->removeComment($comment);
Striktní validace schématu $ php www/index.php \ orm:validate
Entity potřebují tabulky... $ php www/index.php \ orm:schema:up --dump-sql
Proxy třídy kvůli lazy loadingu $ php www/index.php \ orm:generate:proxies
Repository DAO $articles = $entityManager ->getDao(App\Article::getClassName()); $articles = $entityManager ->getDao(App\Article::class);
Ne, repository nestačí... $article = new Article(); $article->title = "The
Tigger Movie"; $articles->save($article); $article = $articles->find(1); echo $article->title; // "The Tigger Movie"
Repozitář umí hezky nabobtnat class ArticlesDao extends EntityDao { function
findByTitle($title); function findByStepmothersBrothersEyeColor(); function findBy...(); }
Hlavně žádné další dědění! class ArticlesDao extends EntityDao { function
findByTitle($title); function findByStepmothersBrothersEyeColor(); function findBy...(); }
Krocení repozitářů http://www.whitewashing.de http://www.whitewashing.de/2013/03/04/doctrine_repositories.html http://filip-prochazka.com/blog/doctrine-a-service-vrstva-aneb-takto-mi-to-dava-smysl
Tak třeba objednávky... OrderModel - Order\UserOpening - Order\Dispatching - Order\Delivery
- ….
Eventy: systémové listenery class EditLogger implements Kdyby\Events\Subscriber { function getSubscribedEvents()
{ return array('postUpdate'); } function postUpdate() { } }
Eventy: systémové listenery services: something: class: App\EditLogger tags: [kdyby.subscriber]
ResultSet $dql = $articles->createQuery("SELECT a FROM Articles a"); $articles =
new Kdyby\Doctrine\ResultSet($dql); $articles->applyPaginator($this['vp']->paginator);
Utilitky Helpers::loadFromFile() Tools\NonLockingUniqueInserter
Dotazy?
Filip Procházka http://filip-prochazka.com http://www.kdyby.org