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.2k
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
19
8.7k
CSRF対策のやり方、そろそろアップデートしませんか / Update your knowledge of CSRF protection
hiro_y
29
24k
PHPで任意精度演算を行って「正しい」金額計算をする方法 / Perform arbitrary precision arithmetic in PHP to achieve "accurate" monetary calculations
hiro_y
2
2.8k
PHPのバージョンアップ実際のところどうなの? / How actually upgrade of PHP is
hiro_y
3
730
PHPのアノテーションの仕組みとメリット・デメリット / About PHP annotations
hiro_y
1
8.3k
株式会社 USEN Media - PHPカンファレンス北海道2019 / 2019-09-21_phpcondo-2019_usen-media
hiro_y
0
210
PHPのmiddlewareを 使いこなすために
hiro_y
3
2.4k
Slim Frameworkで始めるPHPのmiddleware
hiro_y
4
2.1k
Node.jsやPHPでも こわくないHeroku
hiro_y
1
1.6k
Other Decks in Programming
See All in Programming
RWC 2024 DICOM & ISO/IEC 2022
m_seki
0
210
PHPとAPI Platformで作る本格的なWeb APIアプリケーション(入門編) / phpcon 2024 Intro to API Platform
ttskch
0
220
KubeCon + CloudNativeCon NA 2024 Overviewat Kubernetes Meetup Tokyo #68 / amsy810_k8sjp68
masayaaoyama
0
250
「とりあえず動く」コードはよい、「読みやすい」コードはもっとよい / Code that 'just works' is good, but code that is 'readable' is even better.
mkmk884
3
280
nekko cloudにおけるProxmox VE利用事例
irumaru
3
430
Security_for_introducing_eBPF
kentatada
0
110
モバイルアプリにおける自動テストの導入戦略
ostk0069
0
110
開発者とQAの越境で自動テストが増える開発プロセスを実現する
92thunder
1
180
Refactor your code - refactor yourself
xosofox
1
260
これが俺の”自分戦略” プロセスを楽しんでいこう! - Developers CAREER Boost 2024
niftycorp
PRO
0
190
テストコード文化を0から作り、変化し続けた組織
kazatohiei
2
1.5k
LLM Supervised Fine-tuningの理論と実践
datanalyticslabo
5
1.2k
Featured
See All Featured
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
The Pragmatic Product Professional
lauravandoore
32
6.3k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
17
2.3k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
48
2.2k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
127
18k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Site-Speed That Sticks
csswizardry
2
190
Designing Experiences People Love
moore
138
23k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.5k
Why Our Code Smells
bkeepers
PRO
335
57k
Making the Leap to Tech Lead
cromwellryan
133
9k
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