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
32
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
180
Value objects in PHP
fprochazka
1
190
Jak psát testy na REST API
fprochazka
0
95
V gitu se nic neztratí
fprochazka
0
370
Co se PHP programátor může naučit od Javy?
fprochazka
1
120
4 roky remote
fprochazka
1
80
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
61
Other Decks in Technology
See All in Technology
GCASアップデート(202506-202508)
techniczna
0
120
プロダクトエンジニアリングで開発の楽しさを拡張する話
barometrica
0
210
JAWS AI/ML #30 AI コーディング IDE "Kiro" を触ってみよう
inariku
3
400
Autonomous Database Serverless 技術詳細 / adb-s_technical_detail_jp
oracle4engineer
PRO
18
52k
Claude Codeは仕様駆動の夢を見ない
gotalab555
23
7.1k
専門分化が進む分業下でもユーザーが本当に欲しかったものを追求するプロダクトマネジメント/Focus on real user needs despite deep specialization and division of labor
moriyuya
2
1.4k
Lambda management with ecspresso and Terraform
ijin
2
170
ユーザー課題を愛し抜く――AI時代のPdM価値
kakehashi
PRO
1
130
プロジェクトマネジメントは不確実性との対話だ
hisashiwatanabe
0
120
Backlog AI アシスタントが切り開く未来
vvatanabe
1
160
Amazon Bedrock AgentCoreのフロントエンドを探す旅 (Next.js編)
kmiya84377
1
160
夏休みWebアプリパフォーマンス相談室/web-app-performance-on-radio
hachi_eiji
0
260
Featured
See All Featured
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
131
19k
Designing for Performance
lara
610
69k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
31
2.2k
The Straight Up "How To Draw Better" Workshop
denniskardys
236
140k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Being A Developer After 40
akosma
90
590k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.8k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
110
20k
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
9
770
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
139
34k
Large-scale JavaScript Application Architecture
addyosmani
512
110k
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