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
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
84
Other Decks in Technology
See All in Technology
ブラウザ研修 2026
recruitengineers
PRO
4
770
Eight Engineering Unit 紹介資料
sansan33
PRO
3
8.1k
老害フォレンジッカーはAI羊の夢を見るか?
tadmaddad
0
290
20分でわかるセキュアAPI
nwiizo
0
180
修正PRを食べてレビュースキルが賢くなる:Claude Codeによる自己改善サイクル
yuyaumetsu
5
1.4k
メルカリのグローバルアプリで挑んだ AlloyDB 運用と課題解決の実践記
hatappi
0
240
FORENSIA: ローカルLLMフォレンジックハーネス
sumeshi
2
280
Service Connect 上のサービスに ECS Service の外側から到達できなかった話
ota1022
1
150
攻撃と防御で学ぶAI時代のプロダクトセキュリティ演習
recruitengineers
PRO
6
2k
ホームラボ紹介
y_sera15
0
110
Issue設計から始める仕様駆動開発 / 20260731 Mizuki Hirata
shift_evolve
PRO
1
150
変化の早いClaude Codeを 書籍に落とし込む
oikon48
7
1.3k
Featured
See All Featured
Chasing Engaging Ingredients in Design
codingconduct
0
260
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.1k
A Soul's Torment
seathinner
6
3.4k
Believing is Seeing
oripsolob
1
180
SEO for Brand Visibility & Recognition
aleyda
0
4.7k
Code Reviewing Like a Champion
maltzj
528
40k
What does AI have to do with Human Rights?
axbom
PRO
1
2.3k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
200
Navigating Team Friction
lara
192
16k
Statistics for Hackers
jakevdp
799
230k
Utilizing Notion as your number one productivity tool
mfonobong
4
520
The World Runs on Bad Software
bkeepers
PRO
72
12k
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