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
1
2.4k
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
エンジニアの「センス」とは何か / What is the sense of engineers
hiro_y
21
9.4k
CSRF対策のやり方、そろそろアップデートしませんか / Update your knowledge of CSRF protection
hiro_y
30
27k
PHPで任意精度演算を行って「正しい」金額計算をする方法 / Perform arbitrary precision arithmetic in PHP to achieve "accurate" monetary calculations
hiro_y
2
3.3k
PHPのバージョンアップ実際のところどうなの? / How actually upgrade of PHP is
hiro_y
3
780
PHPのアノテーションの仕組みとメリット・デメリット / About PHP annotations
hiro_y
1
8.7k
株式会社 USEN Media - PHPカンファレンス北海道2019 / 2019-09-21_phpcondo-2019_usen-media
hiro_y
0
270
PHPのmiddlewareを 使いこなすために
hiro_y
4
2.5k
Slim Frameworkで始めるPHPのmiddleware
hiro_y
4
2.2k
Node.jsやPHPでも こわくないHeroku
hiro_y
1
1.6k
Other Decks in Programming
See All in Programming
Passkeys for Java Developers
ynojima
1
510
What Spring Developers Should Know About Jakarta EE
ivargrimstad
1
630
TSConfig Solution Style & subpath imports to switch types on a per-file basis
maminami373
1
180
漸進。
ssssota
0
1.3k
技術的負債と戦略的に戦わざるを得ない場合のオブザーバビリティ活用術 / Leveraging Observability When Strategically Dealing with Technical Debt
yoshiyoshifujii
0
160
MLOps Japan 勉強会 #52 - 特徴量を言語を越えて一貫して管理する, 『特徴量ドリブン』な MLOps の実現への試み
taniiicom
2
580
Perlで痩せる
yuukis
1
660
インターフェース設計のコツとツボ
togishima
2
500
【TSkaigi 2025】これは型破り?型安全? 真実はいつもひとつ!(じゃないかもしれない)TypeScript クイズ〜〜〜〜!!!!!
kimitashoichi
1
300
技術懸念に立ち向かい 法改正を穏便に乗り切った話
pop_cashew
0
910
eBPFを用いたAIネットワーク監視システム論文の実装 / eBPF Japan Meetup #4
yuukit
3
630
Spring gRPC で始める gRPC 入門 / Introduction to gRPC with Spring gRPC
mackey0225
0
220
Featured
See All Featured
The Illustrated Children's Guide to Kubernetes
chrisshort
48
50k
Raft: Consensus for Rubyists
vanstee
137
7k
The Power of CSS Pseudo Elements
geoffreycrofte
76
5.8k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
Mobile First: as difficult as doing things right
swwweet
223
9.6k
Building a Modern Day E-commerce SEO Strategy
aleyda
40
7.3k
Automating Front-end Workflow
addyosmani
1370
200k
Navigating Team Friction
lara
186
15k
Building Better People: How to give real-time feedback that sticks.
wjessup
368
19k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
160
15k
Code Review Best Practice
trishagee
68
18k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
123
52k
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