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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
150
コードとあなたと私の距離 / The Distance Between Code, You, and I
hiro_y
0
430
エンジニアの「センス」とは何か / 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
870
PHPのアノテーションの仕組みとメリット・デメリット / About PHP annotations
hiro_y
1
10k
株式会社 USEN Media - PHPカンファレンス北海道2019 / 2019-09-21_phpcondo-2019_usen-media
hiro_y
0
350
PHPのmiddlewareを 使いこなすために
hiro_y
4
2.7k
Other Decks in Programming
See All in Programming
テーブルをDELETEした
yuzneri
0
140
アルゴリズムは何を圧縮しているのか ─ Haskell から育った「圧縮代数」というメンタルモデル
naoya
16
3.9k
komatsuna「分散システムにおけるバグ分析手法」
komatsunaqa
0
240
5分で問診!Composer セキュリティ健康診断
codmoninc
0
890
Laravel Boostに学ぶ、AIにPHPを書かせる技術 〜OSSの実装から蒸留するエージェント制御の王道〜
kentaroutakeda
3
670
FDEが実現するAI駆動経営の現在地
gonta
2
270
霧の中の代数的エフェクト
funnyycat
1
480
言葉の格闘技のススメ~紙とペンと言葉から始める、キャリアの描き方~
progresscicada
2
140
PHP に部分適用が来るぞ!……ところで何それ?おいしいの? #phpcon / phpcon-2026
shogogg
0
580
Terraform標準の組織で AWS CDKをどう使うか
mu7889yoon
1
490
Claude CodeとAgentCore Gatewayを繋ぐ際の認証認可 / Authentication and authorization when connecting Claude Code with AgentCore Gateway
har1101
1
250
夏だ!祭りだ!祭りとはドメインモデリングでは?
ryugen04
0
170
Featured
See All Featured
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
1
390
The Mindset for Success: Future Career Progression
greggifford
PRO
0
440
Building AI with AI
inesmontani
PRO
1
1.1k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
2.1k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
470
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
400
Thoughts on Productivity
jonyablonski
76
5.3k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
630
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
770
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.1k
Ethics towards AI in product and experience design
skipperchong
2
340
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
450
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