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
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
130
V gitu se nic neztratí
fprochazka
0
420
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
85
Other Decks in Technology
See All in Technology
Claude Teamプランの コスト最適化を考える
rfdnxbro
1
830
Claude Codeの体系的な理解と知識のフック
oikon48
9
6.2k
AWSとAzureのマルチクラウド活用における強い味方___AWS_Kiroを使った二刀流スキル作成.pdf
duelist2020jp
1
140
Cloudflare製品を活用した AIガバナンス実践入門 / AI governance with Cloudflare Service
delta_tech
1
130
【5分でわかる】セーフィー エンジニア向け会社紹介
safie_recruit
0
54k
AI × Datadog MCP でコスト削減まで実現した Metric Streams の導入
three_mouth_ago
0
110
信頼性はSREだけのものじゃない
hkawaras
0
370
PdMをやめて、 "プロダクトビルダー"という 働き方に変えました / PdM to Product Builder
shikichee
2
420
研究開発部の紹介 / Sansan R&D Profile
sansan33
PRO
4
24k
Guerilla InnerSource in enterprises, during the AI hype
onenashev
PRO
0
120
LLMアプリ、 雰囲気で運用してませんか? 〜LLMOpsの現在地〜
taka_aki
1
590
Claude Codeで開発以外の業務も爆速化しよう!
minorun365
PRO
11
9.2k
Featured
See All Featured
Java REST API Framework Comparison - PWX 2021
mraible
34
9.7k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
310
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
430
Producing Creativity
orderedlist
PRO
348
40k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
sira's awesome portfolio website redesign presentation
elsirapls
0
360
Skip the Path - Find Your Career Trail
mkilby
1
200
How to train your dragon (web standard)
notwaldorf
97
6.8k
Fashionably flexible responsive web design (full day workshop)
malarkey
408
67k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3k
We Have a Design System, Now What?
morganepeng
55
8.3k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
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