Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
「わたしたちのコード」を安定させるためにフレームワークとの距離を保つ / phperkaig...
Search
blue_goheimochi
March 08, 2024
Technology
5
1.9k
「わたしたちのコード」を安定させるために フレームワークとの距離を保つ / 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.7k
「手動オペレーションに定評がある」と言われた私が心がけていること / phpcon_odawara2024
blue_goheimochi
4
1.4k
芝生の障害対応・メンテナンスについて語る / ya8-2024
blue_goheimochi
1
50
コードを計測することで捉える問題点 / phpcondo2024
blue_goheimochi
5
1.1k
Laravelのコードとわたしたちのコードとの距離を保つ / phpcon2023
blue_goheimochi
1
2k
リンケージにおけるアプリケーションコードとの付き合い方とそれを支えるコミュニケーション / drobe_pixiv_linkage-20230905
blue_goheimochi
1
530
推測しないで、計測し、判断する! 〜カイゼンのためのステップ考察〜 / phpconfuk2023
blue_goheimochi
4
2.2k
iOS, iPadOSにもWeb Pushがきたのでさわってみた
blue_goheimochi
1
480
計測できるレガシーさを捉え、コード改善に対処する / phperkaigi2023
blue_goheimochi
0
2k
Other Decks in Technology
See All in Technology
Explain EXPLAIN
keiko713
10
2.8k
12/3(火)のBedrockアプデ速報(re:Invent 2024 Daily re:Cap #2 with AWS Heroes)
minorun365
PRO
4
140
B10-ひと目でわかる(といいなぁ)Microsoft Purview
seafay
PRO
0
490
WED Company Deck for Engineer
wed
2
3.7k
最近のUplift Modeling手法にRでトライ
hskksk
0
130
スパイクアクセス対策としての pitchfork 導入
riseshia
0
190
属人化したE2E自動テストを ひも解く
honamin09
1
110
Autonomous Database サービス・アップデート (FY25)
oracle4engineer
PRO
0
270
.NET のUnified AI Building Blocks 入門...!
okazuki
0
190
40歲的我會給20歲的自己,關於軟體開發的7個建議
line_developers_tw
PRO
0
2.5k
振る舞い駆動開発(BDD)における、テスト自動化の前に大切にしていること #stac2024 / BDD formulation
nihonbuson
3
1k
asumikamというカンファレンスオーガナイザの凄さを語る / The Brilliance of Asumikam
tomzoh
1
290
Featured
See All Featured
The Cost Of JavaScript in 2023
addyosmani
45
6.9k
Practical Orchestrator
shlominoach
186
10k
Imperfection Machines: The Place of Print at Facebook
scottboms
266
13k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Designing Experiences People Love
moore
138
23k
Product Roadmaps are Hard
iamctodd
PRO
49
11k
The Cult of Friendly URLs
andyhume
78
6.1k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
2
260
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.2k
Producing Creativity
orderedlist
PRO
341
39k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
The World Runs on Bad Software
bkeepers
PRO
65
11k
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 • •