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
Laravelのコードとわたしたちのコードとの距離を保つ / phpcon2023
Search
blue_goheimochi
October 08, 2023
Technology
1
2k
Laravelのコードとわたしたちのコードとの距離を保つ / phpcon2023
PHP Conference Japan 2023の登壇資料です。
https://phpcon.php.gr.jp/2023/
blue_goheimochi
October 08, 2023
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
51
「わたしたちのコード」を安定させるためにフレームワークとの距離を保つ / phperkaigi2024
blue_goheimochi
5
1.9k
コードを計測することで捉える問題点 / phpcondo2024
blue_goheimochi
5
1.1k
リンケージにおけるアプリケーションコードとの付き合い方とそれを支えるコミュニケーション / drobe_pixiv_linkage-20230905
blue_goheimochi
1
540
推測しないで、計測し、判断する! 〜カイゼンのためのステップ考察〜 / phpconfuk2023
blue_goheimochi
4
2.2k
iOS, iPadOSにもWeb Pushがきたのでさわってみた
blue_goheimochi
1
490
計測できるレガシーさを捉え、コード改善に対処する / phperkaigi2023
blue_goheimochi
0
2k
Other Decks in Technology
See All in Technology
re:Invent 2024 Innovation Talks(NET201)で語られた大切なこと
shotashiratori
0
300
アップデート紹介:AWS Data Transfer Terminal
stknohg
PRO
0
170
NilAway による静的解析で「10 億ドル」を節約する #kyotogo / Kyoto Go 56th
ytaka23
3
370
生成AIのガバナンスの全体像と現実解
fnifni
1
180
ブラックフライデーで購入したPixel9で、Gemini Nanoを動かしてみた
marchin1989
1
520
フロントエンド設計にモブ設計を導入してみた / 20241212_cloudsign_TechFrontMeetup
bengo4com
0
1.9k
新機能VPCリソースエンドポイント機能検証から得られた考察
duelist2020jp
0
210
GitHub Copilot のテクニック集/GitHub Copilot Techniques
rayuron
23
11k
サイボウズフロントエンドエキスパートチームについて / FrontendExpert Team
cybozuinsideout
PRO
5
38k
DevOps視点でAWS re:invent2024の新サービス・アプデを振り返ってみた
oshanqq
0
180
KnowledgeBaseDocuments APIでベクトルインデックス管理を自動化する
iidaxs
1
250
私なりのAIのご紹介 [2024年版]
qt_luigi
1
120
Featured
See All Featured
A designer walks into a library…
pauljervisheath
204
24k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
8.3k
Side Projects
sachag
452
42k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.9k
Done Done
chrislema
181
16k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Reflections from 52 weeks, 52 projects
jeffersonlam
347
20k
Become a Pro
speakerdeck
PRO
26
5k
Designing Experiences People Love
moore
138
23k
For a Future-Friendly Web
brad_frost
175
9.4k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
127
18k
Transcript
Laravel PHP Conference Japan 2023 2023.10.08 Yuta Ohashi
2 • Laravel • Laravel • Laravel •
Laravel
4 Laravel PHP Web • 2010 6 1 • 10
2023 2 • 2 • 2024 1 11 • •
5 Laravel [ ] Google Trends Laravel Symfony CakePHP
6 Laravel Laravel - 3 - • • • •
• •
Laravel
8 Laravel • Eloquent • Facede • • Artisan •
9 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
10 Laravel Route Route::post('/tsubuyaki', function ( ) { }); routes/web.php
11 Laravel Route Route::post('/tsubuyaki', function ( ) { }); routes/web.php
/tsubuyaki
12 Laravel Route Route::post('/tsubuyaki', function ( ) { }); routes/web.php
/tsubuyaki POST
13 Laravel Route Route::post('/tsubuyaki', function ( ) { }); routes/web.php
/tsubuyaki POST function
14 Laravel Dependency Injection Request Request $request $text = $request->text;
routes/web.php
15 Laravel Dependency Injection Request Request $request $text = $request->text;
routes/web.php Request DI
16 Laravel Dependency Injection Request Request $request $text = $request->text;
routes/web.php Request DI <input value= text name= text value= /> $request->text
17 Laravel Eloquent $tsubuyaki = new Tsubuyaki; $tsubuyaki->text = $text;
$tsubuyaki->save(); routes/web.php
18 Laravel Eloquent $tsubuyaki = new Tsubuyaki; $tsubuyaki->text = $text;
$tsubuyaki->save(); routes/web.php Eloquent artisan
19 Laravel Eloquent $tsubuyaki = new Tsubuyaki; $tsubuyaki->text = $text;
$tsubuyaki->save(); routes/web.php $text $tsubuyaki->text text Eloquent artisan
20 Laravel Eloquent $tsubuyaki = new Tsubuyaki; $tsubuyaki->text = $text;
$tsubuyaki->save(); routes/web.php $text $tsubuyaki->text text save() Eloquent artisan
21 Laravel redirect return redirect('tsubuyaki/complete'); routes/web.php
22 Laravel redirect return redirect('tsubuyaki/complete'); routes/web.php
23 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
24 Laravel Mailer $mailer $mailer->send(new TsubuyakiCreated()); routes/web.php
25 Laravel Mailer $mailer $mailer->send(new TsubuyakiCreated()); routes/web.php Mailer DI
26 Laravel Mailer $mailer $mailer->send(new TsubuyakiCreated()); routes/web.php Mailer DI Mailable
TsubuyakiCreated artisan
27 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
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 /tsubuyaki POST function <input name= text value= /> $request->text $text $tsubuyaki->text text save() Mailer DI Mailable TsubuyakiCreated artisan Request DI Eloquent artisan
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 Eloquent $text $tsubuyaki->text text save() Mailer DI Request DI Mailable TsubuyakiCreated artisan
30 Laravel • • • Laravel Way 1 •
31 Laravel • • • • 範 • Eloquent ActiveRecode
• • • •
Laravel
33 Laravel Laravel • • Laravel • Laravel • Laravel
• • • Interface
34 Laravel Laravel Laravel
35 Laravel 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
36 Laravel Mailer $mailer $mailer->send(new TsubuyakiCreated()); app/Http/Controllers/TsubuyakiController.php Illuminate¥Mail¥Mailer
37 Laravel app/Http/Controllers/TsubuyakiController.php lib TsubuyakiCreatedSenderInterface namespace Lib¥Mail; interface TsubuyakiCreatedSenderInterface {
public function send(): void; } lib/Mail/TsubuyakiCreatedSenderInterface.php
38 Laravel 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
39 Laravel 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
40 Laravel 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
41 Laravel 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
42 Laravel 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
43 Laravel $tsubuyaki = new Tsubuyaki(); $tsubuyaki->text = $text; $tsubuyaki->save();
app/Http/Controllers/TsubuyakiController.php Eloquent
44 Laravel app/Http/Controllers/TsubuyakiController.php namespace Lib¥Tsubuyaki; interface TsubuyakiUseCaseInterface { public function
save(string $text): void; } lib/Tsubuyaki/TsubuyakiUseCaseInterface.php lib TsubuyakiUseCaseInterface
45 Laravel ; 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
46 Laravel class TsubuyakiUseCase implements TsubuyakiUseCaseInterface { public function save(string
$text): void { $tsubuyaki = new Tsubuyaki(); $tsubuyaki->text = $text; $tsubuyaki->save(); } } app/Tsubuyaki/TsubuyakiUseCase.php TsubuyakiUseCaseInterface app
47 Laravel 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
48 Laravel Interface • • app Laravel • lib Laravel
• Laravel app • lib • • DB
49 Laravel 1 • lib Doctrine • Doctrine ORM Eloquent
• Doctrine • • Eloquent DB
50 Laravel 2 1 • • • UseCase Service •
• DI •
51 Laravel 3 2 • • Mailgun SendGrid • Interface
• MailerResolver • • MailerResolver • • 1
52 Laravel • Laravel Way • • PoC • •
• • •
53 Laravel • • SOLID etc • • • •
None
55 • Laravel • PHP • [ ] • Laravel
• Facade Eloquent • • Laravel • Interface • •
/ @blue_goheimochi , , , , PUBG MOBILE,