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
PHPのDI、attributesとこれから / PHP DI with attributes
Search
YAMAOKA Hiroyuki
March 26, 2021
Programming
2.8k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
PHPのDI、attributesとこれから / PHP DI with attributes
2021年3月28日、PHPerKaigi 2021・Day 2での発表資料です。
https://phperkaigi.jp/2021/
YAMAOKA Hiroyuki
March 26, 2021
More Decks by YAMAOKA Hiroyuki
See All by YAMAOKA Hiroyuki
『タイタン』 - PHPer Book Revue
hiro_y
0
130
コードとあなたと私の距離 / The Distance Between Code, You, and I
hiro_y
0
400
エンジニアの「センス」とは何か / What is the sense of engineers
hiro_y
21
9.9k
CSRF対策のやり方、そろそろアップデートしませんか / Update your knowledge of CSRF protection
hiro_y
32
31k
PHPで任意精度演算を行って「正しい」金額計算をする方法 / Perform arbitrary precision arithmetic in PHP to achieve "accurate" monetary calculations
hiro_y
2
4.2k
PHPのバージョンアップ実際のところどうなの? / How actually upgrade of PHP is
hiro_y
3
860
PHPのアノテーションの仕組みとメリット・デメリット / About PHP annotations
hiro_y
1
9.9k
株式会社 USEN Media - PHPカンファレンス北海道2019 / 2019-09-21_phpcondo-2019_usen-media
hiro_y
0
340
PHPのmiddlewareを 使いこなすために
hiro_y
4
2.7k
Other Decks in Programming
See All in Programming
コンテキストの使い捨てをやめる — ビジネスルール駆動開発と miko —
ioki
0
240
ローカルLLMを使ってB2Bサービスを作っていての学び
yaotti
0
210
AIだと陥りがちなJakarta EE最新技術への移行時の落とし穴と解決策
tnagao7
0
130
act1-costs.pdf
sumedhbala
0
110
OSもどきOS
arkw
0
590
決定論的オーケストレーションの設計と実装 / Design and Implementation of Deterministic Orchestration
nrslib
4
1.5k
Developing with AI Agents — Codex, Claude Code & Cowork Practical Guide
x5gtrn
PRO
0
1.3k
技術記事、 専門家としてのプログラマ、 言語化
mizchi
13
6.5k
AI 輔助遺留系統現代化的經驗分享
jame2408
1
1k
その問い、本当に正しいですか?AI時代のエンジニアに必要な哲学と認知科学 / ai-philosophy-cognitive-science
minodriven
13
6.3k
Vue × Nuxt × Oxc どこまで使える?実運用の現在地
andpad
0
300
ADKを使って簡単にAIエージェントを作ってみよう
k1mu21
0
280
Featured
See All Featured
How to Ace a Technical Interview
jacobian
281
24k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
160
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
200
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
HDC tutorial
michielstock
2
720
My Coaching Mixtape
mlcsv
0
150
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
340
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
150
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
540
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
72
40k
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
310
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.2k
Transcript
PHP DI attributes 2021 3 28 / PHPerKaigi 2 0
2 1 Day 2
- / @hiro_y - PHP Node.js Web - - CTO
- - - - iruca mimemo 👨💻👨💻
- PHPerKaigi 2 0 20 Day 0 - 2020 2
9 - PHP https://speakerdeck.com/hiro_y/about-php-annotations https://www.youtube.com/watch?v=TdHDqOeCUW 4
🎉 PHP 8 . 0 🎉 2020 11
https://www.php.net/releases/ 8 . 0 /ja.php
DI
DI - Dependency: - Injection: class Client { public
function __construct(private Service $service) {} }
PHP DI
DI - Maple https://ja.osdn.net/projects/maple/ - S 2 Container.PHP 5
http://s 2 container.php 5 .seasar.org/ 2 . 0 /ja/index.html - PHP 5
- Java DI - Struts 1 Spring Seasar 2 -
PHP 5 - DI
PHP DI - PHP DI - - Web : -
TDD CI :
PHP 8
PHP - - interface - autoload require - TDD CI
DI - execute($request) : - show(Request $request)
: routing - show(ServerRequestInterface $request) interface :
- IDE PhpStorm VSCode - interface - APC OPcache -
- Symfony Laravel CakePHP - DI - 🕵
- URL - - -
Symfony - Service Container https://symfony.com/doc/ 5 . 2
/components/dependency_injection.html - Dependencyinjection component - PSR- 1 1 - 2
Laravel - Service Container https://laravel.com/docs/ 8 .x/container -
Illuminate\Container\Container - PSR- 1 1 - Facades
: PSR- 1 1 - PSR- 1 1 : Container
Interface https://www.php- fi g.org/psr/psr- 1 1 / - - :
PHP-DI - DI https://php-di.org/ - PSR- 1 1 - Slim
middleware
PHP-DI 7 - 2021 3 10 : beta 3 -
beta - Attributes - PHP 8 PHP-DI 6
PHP-DI 7 - @Inject disabled #[Inject] - - - PhpDocReader
Attributes /** * @Inject({"db.host", "db.name"}) */ public function __construct($param1, $param2)
use DI\Attribute\Inject; #[Inject('db.host', 'db.name')] public function __construct($param1, $param2) ⬇
@Inject - doctrine/annotations - Re fl ection DocComment - DocLexer
-
#[Inject] - PHP 8 Attributes namespace DI\Attribute; use Attribute; #[Attribute(Attribute::TARGET_PROPERTY
| Attribute::TARGET_METHOD | Attribute::TARGET_PARAMETER)] final class Inject {...
DI
Inject - - Inject - Autowire -
Autowire - Inject - - Zero Con fi guration -
PHP-DI DI
Autowire - - class_exists / interface_exists - - interface
autowire DI
None
DI - - - Service -
- - - -
None
DI - - PSR - attributes
None