Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
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
1
2.6k
PHPのDI、attributesとこれから / PHP DI with attributes
2021年3月28日、PHPerKaigi 2021・Day 2での発表資料です。
https://phperkaigi.jp/2021/
YAMAOKA Hiroyuki
March 26, 2021
Tweet
Share
More Decks by YAMAOKA Hiroyuki
See All by YAMAOKA Hiroyuki
コードとあなたと私の距離 / The Distance Between Code, You, and I
hiro_y
0
260
エンジニアの「センス」とは何か / What is the sense of engineers
hiro_y
21
9.7k
CSRF対策のやり方、そろそろアップデートしませんか / Update your knowledge of CSRF protection
hiro_y
32
29k
PHPで任意精度演算を行って「正しい」金額計算をする方法 / Perform arbitrary precision arithmetic in PHP to achieve "accurate" monetary calculations
hiro_y
2
3.8k
PHPのバージョンアップ実際のところどうなの? / How actually upgrade of PHP is
hiro_y
3
820
PHPのアノテーションの仕組みとメリット・デメリット / About PHP annotations
hiro_y
1
9.3k
株式会社 USEN Media - PHPカンファレンス北海道2019 / 2019-09-21_phpcondo-2019_usen-media
hiro_y
0
310
PHPのmiddlewareを 使いこなすために
hiro_y
4
2.6k
Slim Frameworkで始めるPHPのmiddleware
hiro_y
4
2.3k
Other Decks in Programming
See All in Programming
FluorTracer / RayTracingCamp11
kugimasa
0
230
宅宅自以為的浪漫:跟 AI 一起為自己辦的研討會寫一個售票系統
eddie
0
500
ローターアクトEクラブ アメリカンナイト:川端 柚菜 氏(Japan O.K. ローターアクトEクラブ 会長):2720 Japan O.K. ロータリーEクラブ2025年12月1日卓話
2720japanoke
0
730
Go コードベースの構成と AI コンテキスト定義
andpad
0
120
UIデザインに役立つ 2025年の最新CSS / The Latest CSS for UI Design 2025
clockmaker
18
7.4k
MAP, Jigsaw, Code Golf 振り返り会 by 関東Kaggler会|Jigsaw 15th Solution
hasibirok0
0
240
Rediscover the Console - SymfonyCon Amsterdam 2025
chalasr
2
160
How Software Deployment tools have changed in the past 20 years
geshan
0
29k
モデル駆動設計をやってみようワークショップ開催報告(Modeling Forum2025) / model driven design workshop report
haru860
0
270
AtCoder Conference 2025「LLM時代のAHC」
imjk
2
480
Full-Cycle Reactivity in Angular: SignalStore mit Signal Forms und Resources
manfredsteyer
PRO
0
140
20251127_ぼっちのための懇親会対策会議
kokamoto01_metaps
2
430
Featured
See All Featured
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.3k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
196
70k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
9.8k
Balancing Empowerment & Direction
lara
5
800
Java REST API Framework Comparison - PWX 2021
mraible
34
9k
How to Think Like a Performance Engineer
csswizardry
28
2.4k
Context Engineering - Making Every Token Count
addyosmani
9
510
Done Done
chrislema
186
16k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.3k
Being A Developer After 40
akosma
91
590k
Automating Front-end Workflow
addyosmani
1371
200k
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