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.6k
「手動オペレーションに定評がある」と言われた私が心がけていること / phpcon_odawara2024
blue_goheimochi
4
1.2k
芝生の障害対応・メンテナンスについて語る / ya8-2024
blue_goheimochi
1
46
「わたしたちのコード」を安定させるためにフレームワークとの距離を保つ / phperkaigi2024
blue_goheimochi
5
1.9k
コードを計測することで捉える問題点 / phpcondo2024
blue_goheimochi
5
1k
リンケージにおけるアプリケーションコードとの付き合い方とそれを支えるコミュニケーション / 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
Introduction to Works of ML Engineer in LY Corporation
lycorp_recruit_jp
0
140
IBC 2024 動画技術関連レポート / IBC 2024 Report
cyberagentdevelopers
PRO
1
110
ドメインの本質を掴む / Get the essence of the domain
sinsoku
2
160
Python(PYNQ)がテーマのAMD主催のFPGAコンテストに参加してきた
iotengineer22
0
500
Zennのパフォーマンスモニタリングでやっていること
ryosukeigarashi
0
150
B2B SaaSから見た最近のC#/.NETの進化
sansantech
PRO
0
890
10XにおけるData Contractの導入について: Data Contract事例共有会
10xinc
6
660
第1回 国土交通省 データコンペ参加者向け勉強会③- Snowflake x estie編 -
estie
0
130
CDCL による厳密解法を採用した MILP ソルバー
imai448
3
130
ISUCONに強くなるかもしれない日々の過ごしかた/Findy ISUCON 2024-11-14
fujiwara3
8
870
オープンソースAIとは何か? --「オープンソースAIの定義 v1.0」詳細解説
shujisado
9
1.1k
TanStack Routerに移行するのかい しないのかい、どっちなんだい! / Are you going to migrate to TanStack Router or not? Which one is it?
kaminashi
0
600
Featured
See All Featured
Docker and Python
trallard
40
3.1k
For a Future-Friendly Web
brad_frost
175
9.4k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
720
Done Done
chrislema
181
16k
Visualization
eitanlees
145
15k
Six Lessons from altMBA
skipperchong
27
3.5k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
Art, The Web, and Tiny UX
lynnandtonic
297
20k
Embracing the Ebb and Flow
colly
84
4.5k
Side Projects
sachag
452
42k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
8.2k
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,