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
Filip Procházka
October 27, 2013
Technology
0
33
Usnadněte si soužití s Doctrine
Filip Procházka
October 27, 2013
Tweet
Share
More Decks by Filip Procházka
See All by Filip Procházka
Evolving architecture
fprochazka
0
200
Value objects in PHP
fprochazka
1
200
Jak psát testy na REST API
fprochazka
0
100
V gitu se nic neztratí
fprochazka
0
380
Co se PHP programátor může naučit od Javy?
fprochazka
1
120
4 roky remote
fprochazka
1
81
Před čím tě Nette ani Symfony neochrání
fprochazka
0
150
Nejlepší cache je žádná cache
fprochazka
0
120
Doctrine: co dělat, když entity nestačí
fprochazka
0
63
Other Decks in Technology
See All in Technology
Azure Well-Architected Framework入門
tomokusaba
0
280
PythonとLLMで挑む、 4コマ漫画の構造化データ化
esuji5
1
130
"複雑なデータ処理 × 静的サイト" を両立させる、楽をするRails運用 / A low-effort Rails workflow that combines “Complex Data Processing × Static Sites”
hogelog
3
1.9k
組織観点からIAM Identity CenterとIAMの設計を考える
nrinetcom
PRO
1
160
PLaMoの事後学習を支える技術 / PFN LLMセミナー
pfn
PRO
9
3.8k
許しとアジャイル
jnuank
1
110
SoccerNet GSRの紹介と技術応用:選手視点映像を提供するサッカー作戦盤ツール
mixi_engineers
PRO
1
160
バイブコーディングと継続的デプロイメント
nwiizo
2
410
Exadata Database Service on Dedicated Infrastructure(ExaDB-D) UI スクリーン・キャプチャ集
oracle4engineer
PRO
2
5.4k
Why React!?? Next.jsそしてReactを改めてイチから選ぶ
ypresto
10
4.4k
Findy Team+のSOC2取得までの道のり
rvirus0817
0
310
20250929_QaaS_vol20
mura_shin
0
110
Featured
See All Featured
Testing 201, or: Great Expectations
jmmastey
45
7.7k
Rebuilding a faster, lazier Slack
samanthasiow
84
9.2k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.5k
Learning to Love Humans: Emotional Interface Design
aarron
274
40k
Navigating Team Friction
lara
189
15k
Into the Great Unknown - MozCon
thekraken
40
2.1k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
1.6k
Done Done
chrislema
185
16k
Side Projects
sachag
455
43k
Reflections from 52 weeks, 52 projects
jeffersonlam
352
21k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
132
19k
A Tale of Four Properties
chriscoyier
160
23k
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