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
1.8k
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
CSRF対策のやり方、そろそろアップデートしませんか / Update your knowledge of CSRF protection
hiro_y
26
19k
PHPで任意精度演算を行って「正しい」金額計算をする方法 / Perform arbitrary precision arithmetic in PHP to achieve "accurate" monetary calculations
hiro_y
2
1.6k
PHPのバージョンアップ実際のところどうなの? / How actually upgrade of PHP is
hiro_y
3
620
PHPのアノテーションの仕組みとメリット・デメリット / About PHP annotations
hiro_y
1
7.5k
株式会社 USEN Media - PHPカンファレンス北海道2019 / 2019-09-21_phpcondo-2019_usen-media
hiro_y
0
140
PHPのmiddlewareを 使いこなすために
hiro_y
3
2.2k
Slim Frameworkで始めるPHPのmiddleware
hiro_y
4
1.9k
Node.jsやPHPでも こわくないHeroku
hiro_y
1
1.4k
やりたいことがひとつではない会社のはなし
hiro_y
0
770
Other Decks in Programming
See All in Programming
Kotlin Multiplatform at Stable and Beyond (Android Makers 2024)
zsmb
0
550
Effectで作る堅牢でスケーラブルなAPIゲートウェイ / Robust and Scalable API Gateway Built on Effect
yasaichi
2
110
Revisiting the Hotwire Landscape after Turbo 8 @ RailsConf 2024, Detroit
marcoroth
0
380
Docker_OSS_ホスティング入門
satokoki645
0
110
Balkan Ruby 2024 — How and why to run SQLite on Rails in production
fractaledmind
0
110
初心者のためのRubyKaigi入門/RubyKaigi Introduction
a_matsuda
10
1.7k
Snowflakeで眠ったデータを起こそう!
estie
0
160
Komplexe Oberflächen mit SVG und der Web Animation API
joergneumann
0
690
Scalable Customer Journey Orchestration (CJO)
lewuathe
0
450
Criando a Woovi em uma semana
daniloab
0
100
slow types ってなんだろう?
karad
0
180
ServerAction で Progressive Enhancement はどこまで頑張れるか? / progressive-enhancement-with-server-action
takefumiyoshii
6
480
Featured
See All Featured
Music & Morning Musume
bryan
41
5.6k
What's new in Ruby 2.0
geeforr
337
31k
Rails Girls Zürich Keynote
gr2m
91
13k
The Brand Is Dead. Long Live the Brand.
mthomps
49
29k
Building a Modern Day E-commerce SEO Strategy
aleyda
22
6.4k
Fashionably flexible responsive web design (full day workshop)
malarkey
398
65k
RailsConf 2023
tenderlove
9
570
The MySQL Ecosystem @ GitHub 2015
samlambert
244
12k
Designing for humans not robots
tammielis
247
25k
Keith and Marios Guide to Fast Websites
keithpitt
408
22k
GraphQLとの向き合い方2022年版
quramy
33
12k
GraphQLの誤解/rethinking-graphql
sonatard
56
9.3k
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