PHPのDI、attributesとこれから / PHP DI with attributes
by
YAMAOKA Hiroyuki
Link
Embed
Share
Beginning
This slide
Copy link URL
Copy link URL
Copy iframe embed code
Copy iframe embed code
Copy javascript embed code
Copy javascript embed code
Share
Tweet
Share
Tweet
Slide 1
Slide 1 text
PHP DI attributes 2021 3 28 / PHPerKaigi 2 0 2 1 Day 2
Slide 2
Slide 2 text
- / @hiro_y - PHP Node.js Web - - CTO
Slide 3
Slide 3 text
- - - - iruca mimemo 👨💻👨💻
Slide 4
Slide 4 text
- 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
Slide 5
Slide 5 text
🎉 PHP 8 . 0 🎉 2020 11
Slide 6
Slide 6 text
https://www.php.net/releases/ 8 . 0 /ja.php
Slide 7
Slide 7 text
DI
Slide 8
Slide 8 text
DI - Dependency: - Injection: class Client { public function __construct(private Service $service) {} }
Slide 9
Slide 9 text
PHP DI
Slide 10
Slide 10 text
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
Slide 11
Slide 11 text
- Java DI - Struts 1 Spring Seasar 2 - PHP 5 - DI
Slide 12
Slide 12 text
PHP DI - PHP DI - - Web : - TDD CI :
Slide 13
Slide 13 text
PHP 8
Slide 14
Slide 14 text
PHP - - interface - autoload require - TDD CI
Slide 15
Slide 15 text
DI - execute($request) : - show(Request $request) : routing - show(ServerRequestInterface $request) interface :
Slide 16
Slide 16 text
- IDE PhpStorm VSCode - interface - APC OPcache -
Slide 17
Slide 17 text
- Symfony Laravel CakePHP - DI - 🕵
Slide 18
Slide 18 text
- URL - - -
Slide 19
Slide 19 text
Symfony - Service Container https://symfony.com/doc/ 5 . 2 /components/dependency_injection.html - Dependencyinjection component - PSR- 1 1 - 2
Slide 20
Slide 20 text
Laravel - Service Container https://laravel.com/docs/ 8 .x/container - Illuminate\Container\Container - PSR- 1 1 - Facades
Slide 21
Slide 21 text
: PSR- 1 1 - PSR- 1 1 : Container Interface https://www.php- fi g.org/psr/psr- 1 1 / - - :
Slide 22
Slide 22 text
PHP-DI - DI https://php-di.org/ - PSR- 1 1 - Slim middleware
Slide 23
Slide 23 text
PHP-DI 7 - 2021 3 10 : beta 3 - beta - Attributes - PHP 8 PHP-DI 6
Slide 24
Slide 24 text
PHP-DI 7 - @Inject disabled #[Inject] - - - PhpDocReader
Slide 25
Slide 25 text
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) ⬇
Slide 26
Slide 26 text
@Inject - doctrine/annotations - Re fl ection DocComment - DocLexer -
Slide 27
Slide 27 text
#[Inject] - PHP 8 Attributes namespace DI\Attribute; use Attribute; #[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_METHOD | Attribute::TARGET_PARAMETER)] final class Inject {...
Slide 28
Slide 28 text
DI
Slide 29
Slide 29 text
Inject - - Inject - Autowire -
Slide 30
Slide 30 text
Autowire - Inject - - Zero Con fi guration - PHP-DI DI
Slide 31
Slide 31 text
Autowire - - class_exists / interface_exists - - interface
Slide 32
Slide 32 text
autowire DI
Slide 33
Slide 33 text
No content
Slide 34
Slide 34 text
DI - - - Service -
Slide 35
Slide 35 text
- - - -
Slide 36
Slide 36 text
No content
Slide 37
Slide 37 text
DI - - PSR - attributes
Slide 38
Slide 38 text
No content