Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Usnadněte si soužití s Doctrine
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Filip Procházka
October 27, 2013
Technology
38
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
Transcript
24 slides
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
More Decks by Filip Procházka
See All by Filip Procházka
Evolving architecture
fprochazka
0
260
Value objects in PHP
fprochazka
1
250
Jak psát testy na REST API
fprochazka
0
140
V gitu se nic neztratí
fprochazka
0
420
Co se PHP programátor může naučit od Javy?
fprochazka
1
160
4 roky remote
fprochazka
1
95
Před čím tě Nette ani Symfony neochrání
fprochazka
0
170
Nejlepší cache je žádná cache
fprochazka
0
140
Doctrine: co dělat, když entity nestačí
fprochazka
0
89
Other Decks in Technology
See All in Technology
自動計装なしでECSサービスをApplication Signalsに載せるまで
ota1022
2
470
IVRy における AI 時代のデータプロダクトと事業開発
ivry_presentationmaterials
0
110
Taking back control of your AI development
inesmontani
PRO
0
310
パスワードのない鍵で、 データを手元に置く
ginjihayashi
0
400
Dark Web - Como o Cibercrime Opera na Internet
nicholsjasper
0
110
実測データからサービスの成長余力を測る。負荷シナリオ・テストデータ・限界値の設計
kazatohiei
0
170
業務の傍らで進める改善ループエンジニアリング
bengo4com
1
240
常時稼働エージェントの作り方(Claude公式ブログを資料化)
minorun365
PRO
20
29k
Terraform 0 to 100:100個以上のリポジトリを常に最新にし続けるための自動化
sue445
3
1.4k
Amazon EFS のマルウェアスキャンをClamAV で自前実装したら苦労した話
mtmtfactory01
0
110
ワークフローからハーネスへ — Web フレームワークの作者たちが AI エージェントに向かう理由
azukiazusa1
2
1k
新規事業開発でのAWS活用成功談&失敗談! 〜新規事業開発を専門に行うRelicならではのAWS活用〜
amixedcolor
1
140
Featured
See All Featured
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
203
77k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
700
Web Performance Is a Journey [PerfNow 2026]
tammyeverts
2
150
Visualization
eitanlees
153
17k
Amusing Abliteration
ianozsvald
1
400
Building Adaptive Systems
keathley
44
3.3k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
2
530
The Spectacular Lies of Maps
axbom
PRO
1
1.1k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
1
250
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.3k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
Fireside Chat
paigeccino
43
4.1k