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
「わたしたちのコード」を安定させるためにフレームワークとの距離を保つ / phperkaig...
Search
blue_goheimochi
March 08, 2024
Technology
5
1.8k
「わたしたちのコード」を安定させるために フレームワークとの距離を保つ / phperkaigi2024
PHPerKaigi 2024の登壇資料です。
https://phperkaigi.jp/2024/
blue_goheimochi
March 08, 2024
Tweet
Share
More Decks by blue_goheimochi
See All by blue_goheimochi
コミュニケーションを「パス」のやりとりと捉え大切にしていること / dai-kichijojipm-2024
blue_goheimochi
2
2.6k
「手動オペレーションに定評がある」と言われた私が心がけていること / phpcon_odawara2024
blue_goheimochi
4
1.2k
芝生の障害対応・メンテナンスについて語る / ya8-2024
blue_goheimochi
1
46
コードを計測することで捉える問題点 / phpcondo2024
blue_goheimochi
5
1k
Laravelのコードとわたしたちのコードとの距離を保つ / phpcon2023
blue_goheimochi
1
2k
リンケージにおけるアプリケーションコードとの付き合い方とそれを支えるコミュニケーション / drobe_pixiv_linkage-20230905
blue_goheimochi
1
520
推測しないで、計測し、判断する! 〜カイゼンのためのステップ考察〜 / phpconfuk2023
blue_goheimochi
4
2.1k
iOS, iPadOSにもWeb Pushがきたのでさわってみた
blue_goheimochi
1
470
計測できるレガシーさを捉え、コード改善に対処する / phperkaigi2023
blue_goheimochi
0
1.9k
Other Decks in Technology
See All in Technology
Windows Autopilot Deployment by OSD Guy
tamaiyutaro
0
410
リンクアンドモチベーション ソフトウェアエンジニア向け紹介資料 / Introduction to Link and Motivation for Software Engineers
lmi
4
300k
dev 補講: プロダクトセキュリティ / Product security overview
wa6sn
0
1.9k
ドメインの本質を掴む / Get the essence of the domain
sinsoku
2
140
OCI Vault 概要
oracle4engineer
PRO
0
9.7k
組み込みLinuxの時系列
puhitaku
4
1.1k
SREによる隣接領域への越境とその先の信頼性
shonansurvivors
2
470
"君は見ているが観察していない"で考えるインシデントマネジメント
grimoh
4
1.2k
フルカイテン株式会社 採用資料
fullkaiten
0
40k
インフラとバックエンドとフロントエンドをくまなく調べて遅いアプリを早くした件
tubone24
1
390
TypeScript、上達の瞬間
sadnessojisan
43
11k
OCI 運用監視サービス 概要
oracle4engineer
PRO
0
4.7k
Featured
See All Featured
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.8k
Become a Pro
speakerdeck
PRO
25
5k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
27
4.2k
Art, The Web, and Tiny UX
lynnandtonic
297
20k
The Invisible Side of Design
smashingmag
297
50k
Visualization
eitanlees
145
15k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.2k
A designer walks into a library…
pauljervisheath
202
24k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
33k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
Fireside Chat
paigeccino
33
3k
Transcript
PHPerKaigi 2024 2024.03.08 Yuta Ohashi
/ @blue_goheimochi , , , , PUBG MOBILE,
3 • Laravel • Laravel • •
Laravel
5 Laravel PHP Web • 2010 6 1 • 10
2023 2 • 2 • 2024 3 12 11 • • 2024 •
6 Laravel [ ] Google Trends Laravel Symfony CakePHP
7 Laravel Laravel - 3 - • • • •
• •
Laravel
9 Laravel • Eloquent • Facede • • Artisan •
10 Laravel Route::post('/tsubuyaki', function (Request $request) { $text = $request->text;
$tsubuyaki = new Tsubuyaki; $tsubuyaki->text = $text; $tsubuyaki->save(); return redirect('tsubuyaki/complete'); }); routes/web.php
11 Laravel Route Route::post('/tsubuyaki', function ( ) { }); routes/web.php
12 Laravel Route Route::post('/tsubuyaki', function ( ) { }); routes/web.php
/tsubuyaki
13 Laravel Route Route::post('/tsubuyaki', function ( ) { }); routes/web.php
/tsubuyaki POST
14 Laravel Route Route::post('/tsubuyaki', function ( ) { }); routes/web.php
/tsubuyaki POST function
15 Laravel Dependency Injection Request Request $request $text = $request->text;
routes/web.php
16 Laravel Dependency Injection Request Request $request $text = $request->text;
routes/web.php Request DI
17 Laravel Dependency Injection Request Request $request $text = $request->text;
routes/web.php Request DI <input value= text name= text value= /> $request->text
18 Laravel Eloquent $tsubuyaki = new Tsubuyaki; $tsubuyaki->text = $text;
$tsubuyaki->save(); routes/web.php
19 Laravel Eloquent $tsubuyaki = new Tsubuyaki; $tsubuyaki->text = $text;
$tsubuyaki->save(); routes/web.php Eloquent artisan
20 Laravel Eloquent $tsubuyaki = new Tsubuyaki; $tsubuyaki->text = $text;
$tsubuyaki->save(); routes/web.php $text $tsubuyaki->text text Eloquent artisan
21 Laravel Eloquent $tsubuyaki = new Tsubuyaki; $tsubuyaki->text = $text;
$tsubuyaki->save(); routes/web.php $text $tsubuyaki->text text save() Eloquent artisan
22 Laravel redirect return redirect('tsubuyaki/complete'); routes/web.php
23 Laravel redirect return redirect('tsubuyaki/complete'); routes/web.php
24 Laravel Route::post('/tsubuyaki', function (Request $request) { $text = $request->text;
$tsubuyaki = new Tsubuyaki; $tsubuyaki->text = $text; $tsubuyaki->save(); return redirect('tsubuyaki/complete'); }); routes/web.php
25 Laravel Mailer $mailer $mailer->send(new TsubuyakiCreated()); routes/web.php
26 Laravel Mailer $mailer $mailer->send(new TsubuyakiCreated()); routes/web.php Mailer DI
27 Laravel Mailer $mailer $mailer->send(new TsubuyakiCreated()); routes/web.php Mailer DI Mailable
TsubuyakiCreated artisan
28 Laravel Route::post('/tsubuyaki', function (Request $request, Mailer $mailer) { $text
= $request->text; $tsubuyaki = new Tsubuyaki; $tsubuyaki->text = $text; $tsubuyaki->save(); $mailer->send(new TsubuyakiCreated()); return redirect('tsubuyaki/complete'); }); routes/web.php
29 Laravel Route::post('/tsubuyaki', function (Request $request, Mailer $mailer) { $text
= $request->text; $tsubuyaki = new Tsubuyaki; $tsubuyaki->text = $text; $tsubuyaki->save(); $mailer->send(new TsubuyakiCreated()); return redirect('tsubuyaki/complete'); }); routes/web.php /tsubuyaki POST function <input name= text value= /> $request->text $text $tsubuyaki->text text save() Mailer DI Mailable TsubuyakiCreated artisan Request DI Eloquent artisan
30 Laravel Route::post('/tsubuyaki', function (Request $request, Mailer $mailer) { $text
= $request->text; $tsubuyaki = new Tsubuyaki; $tsubuyaki->text = $text; $tsubuyaki->save(); $mailer->send(new TsubuyakiCreated()); return redirect('tsubuyaki/complete'); }); routes/web.php /tsubuyaki POST function <input name= text value= /> $request->text Eloquent $text $tsubuyaki->text text save() Mailer DI Request DI Mailable TsubuyakiCreated artisan
31 Laravel • • • Laravel Way 1 •
32 Laravel • • • • 範 • Eloquent ActiveRecode
• • • •
フレームワークとわたしたちのコードの 距離を保つために
34 Laravel • • Laravel • Laravel • Laravel •
• • Interface
35 Laravel Laravel
36 class TsubuyakiController extends Controller { public function store(Request $request,
Mailer $mailer): RedirectResponse { $text = $request->text; $tsubuyaki = new Tsubuyaki(); $tsubuyaki->text = $text; $tsubuyaki->save(); $mailer->send(new TsubuyakiCreated()); return redirect('tsubuyaki/complete'); } } app/Http/Controllers/TsubuyakiController.php routes/web.php
37 Mailer $mailer $mailer->send(new TsubuyakiCreated()); app/Http/Controllers/TsubuyakiController.php Illuminate¥Mail¥Mailer
38 app/Http/Controllers/TsubuyakiController.php lib TsubuyakiCreatedSenderInterface namespace Lib¥Mail; interface TsubuyakiCreatedSenderInterface { public
function send(): void; } lib/Mail/TsubuyakiCreatedSenderInterface.php
39 use Lib¥Mail¥TsubuyakiCreatedSenderInterface as SenderInterface; SenderInterface $sender $sender->send(); app/Http/Controllers/TsubuyakiController.php namespace
Lib¥Mail; interface TsubuyakiCreatedSenderInterface { public function send(): void; } lib/Mail/TsubuyakiCreatedSenderInterface.php Interface
40 use Lib¥Mail¥TsubuyakiCreatedSenderInterface as SenderInterface; SenderInterface $sender $sender->send(); app/Http/Controllers/TsubuyakiController.php Interface
Mailer namespace Lib¥Mail; interface TsubuyakiCreatedSenderInterface { public function send(): void; } lib/Mail/TsubuyakiCreatedSenderInterface.php
41 class TsubuyakiCreatedSender implements TsubuyakiCreatedSenderInterface { public function __construct(private readonly
Mailer $mailer) {} public function send(): void { $this->$mailer->send(new TsubuyakiCreated()); } } app/Mail/TsubuyakiCreatedSender.php TsubuyakiCreatedSenderInterface app
42 class TsubuyakiCreatedSender implements TsubuyakiCreatedSenderInterface { public function __construct(private readonly
Mailer $mailer) {} public function send(): void { $this->$mailer->send(new TsubuyakiCreated()); } } app/Mail/TsubuyakiCreatedSender.php class AppServiceProvider extends ServiceProvider { public array $bindings = [ Lib¥Mail¥TsubuyakiCreatedSenderInterface::class => ¥App¥Mail¥TsubuyakiCreatedSender::class, ]; } app/Providers/AppServiceProvider.php
43 use Lib¥Mail¥TsubuyakiCreatedSenderInterface as SenderInterface; class TsubuyakiController extends Controller {
public function store(Request $request, SenderInterface $sender): RedirectResponse { $text = $request->text; $tsubuyaki = new Tsubuyaki(); $tsubuyaki->text = $text; $tsubuyaki->save(); $sender->send(); return redirect('tsubuyaki/complete'); } } app/Http/Controllers/TsubuyakiController.php
44 $tsubuyaki = new Tsubuyaki(); $tsubuyaki->text = $text; $tsubuyaki->save(); app/Http/Controllers/TsubuyakiController.php
Eloquent
45 app/Http/Controllers/TsubuyakiController.php namespace Lib¥Tsubuyaki; interface TsubuyakiUseCaseInterface { public function save(string
$text): void; } lib/Tsubuyaki/TsubuyakiUseCaseInterface.php lib TsubuyakiUseCaseInterface
46 ; use Lib¥Tsubuyaki¥TsubuyakiUseCaseInterface; TsubuyakiUseCaseInterface $useCase $useCase->save($text); app/Http/Controllers/TsubuyakiController.php namespace Lib¥Tsubuyaki;
interface TsubuyakiUseCaseInterface { public function save(string $text): void; } lib/Tsubuyaki/TsubuyakiUseCaseInterface.php Interface Eloquent
47 class TsubuyakiUseCase implements TsubuyakiUseCaseInterface { public function save(string $text):
void { $tsubuyaki = new Tsubuyaki(); $tsubuyaki->text = $text; $tsubuyaki->save(); } } app/Tsubuyaki/TsubuyakiUseCase.php TsubuyakiUseCaseInterface app
48 class TsubuyakiUseCase implements TsubuyakiUseCaseInterface { public function __construct(private readonly
EntityManager $em) {} public function save(string $text): void { $tsubuyaki = new Tsubuyaki(); $tsubuyaki->setText($text); $em->persist($tsubuyaki); $em->flush(); } } app/Tsubuyaki/TsubuyakiUseCase.php Doctrine
49 Interface • • app Laravel • lib Laravel •
Laravel app • lib • • DB
50 1 • lib Doctrine • Doctrine ORM Eloquent •
Doctrine • • Eloquent DB
51 2 1 • • • UseCase Service • •
DI •
52 3 2 • • Mailgun SendGrid • Interface •
MailerResolver • • MailerResolver • • 1
53 • Laravel Way • • PoC • • •
• •
54 • • SOLID etc • • • •
None
56 • Laravel • Laravel PHP • [ ] •
Laravel • Facade Eloquent • • • Interface • •