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 をおうちで楽しんでみた ~CloudWatch のオブザーバビリティ機能がスゴい!/ Enjoyed AWS re:Invent from Home and CloudWatch Observability Feature is Amazing!
yuj1osm
0
130
KubeCon NA 2024 Recap / Running WebAssembly (Wasm) Workloads Side-by-Side with Container Workloads
z63d
1
250
PHPerのための計算量入門/Complexity101 for PHPer
hanhan1978
5
150
祝!Iceberg祭開幕!re:Invent 2024データレイク関連アップデート10分総ざらい
kniino
3
300
OpenAIの蒸留機能(Model Distillation)を使用して運用中のLLMのコストを削減する取り組み
pharma_x_tech
4
560
大幅アップデートされたRagas v0.2をキャッチアップ
os1ma
2
540
サイボウズフロントエンドエキスパートチームについて / FrontendExpert Team
cybozuinsideout
PRO
5
38k
LINEスキマニにおけるフロントエンド開発
lycorptech_jp
PRO
0
330
【re:Invent 2024 アプデ】 Prompt Routing の紹介
champ
0
150
社内イベント管理システムを1週間でAKSからACAに移行した話し
shingo_kawahara
0
190
KubeCon NA 2024 Recap: How to Move from Ingress to Gateway API with Minimal Hassle
ysakotch
0
200
フロントエンド設計にモブ設計を導入してみた / 20241212_cloudsign_TechFrontMeetup
bengo4com
0
1.9k
Featured
See All Featured
A designer walks into a library…
pauljervisheath
204
24k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
Adopting Sorbet at Scale
ufuk
73
9.1k
Designing on Purpose - Digital PM Summit 2013
jponch
116
7k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.9k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
26
1.9k
The Art of Programming - Codeland 2020
erikaheidi
53
13k
The Cost Of JavaScript in 2023
addyosmani
45
7k
Embracing the Ebb and Flow
colly
84
4.5k
Statistics for Hackers
jakevdp
796
220k
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,