$30 off During Our Annual Pro Sale. View Details »
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.3k
芝生の障害対応・メンテナンスについて語る / ya8-2024
blue_goheimochi
1
49
「わたしたちのコード」を安定させるためにフレームワークとの距離を保つ / phperkaigi2024
blue_goheimochi
5
1.9k
コードを計測することで捉える問題点 / phpcondo2024
blue_goheimochi
5
1.1k
リンケージにおけるアプリケーションコードとの付き合い方とそれを支えるコミュニケーション / drobe_pixiv_linkage-20230905
blue_goheimochi
1
530
推測しないで、計測し、判断する! 〜カイゼンのためのステップ考察〜 / phpconfuk2023
blue_goheimochi
4
2.1k
iOS, iPadOSにもWeb Pushがきたのでさわってみた
blue_goheimochi
1
480
計測できるレガシーさを捉え、コード改善に対処する / phperkaigi2023
blue_goheimochi
0
2k
Other Decks in Technology
See All in Technology
エンジニアの草の根活動のその先へ LINEギフトのアクセシビリティにおける ネクストアクション
lycorptech_jp
PRO
0
110
歴史あるRuby on Railsでデッドコードを見つけ、 消す方法@yabaibuki.dev #3
ayumu838
0
1.7k
品質管理チームのEMとして大事にしていること / QA EM
nihonbuson
0
260
asumikamというカンファレンスオーガナイザの凄さを語る / The Brilliance of Asumikam
tomzoh
1
170
TimeTreeが経た3つの転換点 ー プロダクト成長過程でその時、その瞬間、何を考えてたか
ysmtysts
0
210
Amazon ECSとCloud Runの相互理解で広げるクラウドネイティブの景色 / Mutually understanding Amazon ECS and Cloud Run
iselegant
18
2.3k
偶有的複雑性と戦うためのアーキテクチャとチームトポロジー
knih
7
6.1k
Kubernetes だけじゃない!Amazon ECS で実現するクラウドネイティブな GitHub Actions セルフホストランナー / CNDW2024
ponkio_o
PRO
6
420
店舗向けSaaSにおける 顧客要望活用の実践アプローチ(20241205_pmconf)
yujirooo
0
100
プロダクトマネージャーは 事業責任者の夢をみるのか pmconf2024
gimupop
0
990
複雑なCI/CDから脱却したアーキテクチャ:NTTグループの内製プラットフォーム事例を通して / An Architecture Achieving Simplified CI/CD: Insights from NTT Group's In-House Platform Case Study
nttcom
0
200
【ASW21-01】STAMPSTPAで導き出した課題に対する対策立案手法の提案
hianraku9498
0
230
Featured
See All Featured
What's new in Ruby 2.0
geeforr
343
31k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
How To Stay Up To Date on Web Technology
chriscoyier
789
250k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Designing the Hi-DPI Web
ddemaree
280
34k
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.3k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
4 Signs Your Business is Dying
shpigford
181
21k
Writing Fast Ruby
sferik
627
61k
Unsuck your backbone
ammeep
669
57k
Navigating Team Friction
lara
183
15k
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,