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
Laravel5.5のアプデ内容を勝手に評価してみた
Search
kotamat
September 13, 2017
Programming
0
560
Laravel5.5のアプデ内容を勝手に評価してみた
2017-09-13開催されたLaralab vol.1
https://laralab.connpass.com/event/65160
の発表内容です
kotamat
September 13, 2017
Tweet
Share
More Decks by kotamat
See All by kotamat
LLMを用いた対話システムサービスをどうやって立ち 上げていくか? / How to launch a dialogue system service using LLM (Large Language Model)?
kotamat
0
350
ChatGPT×Whisperのプロトタイプと今後の展望 / chatgpt-with-whisper-prototyping-and-future-prospects
kotamat
3
3.2k
プロダクトドリブンにするために行った技術投資 / tech investment for product driven
kotamat
1
790
CTOがなぜPMをやりはじめたのか / Why did the CTO start doing PM
kotamat
0
220
プロダクトを中心に考える#とは / focus on the product
kotamat
1
1.9k
スタートアップに入ってまずやったインフラTIPS
kotamat
2
4.7k
NuxtMeetup#1
kotamat
1
3.1k
Laravel_Nuxtjsでの構成とつまづきポイント
kotamat
1
1k
Laravelでプチマイクロサービスやってみた
kotamat
1
5.4k
Other Decks in Programming
See All in Programming
Symfony Mapper Component
soyuka
2
730
MCP with Cloudflare Workers
yusukebe
2
220
HTTP compression in PHP and Symfony apps
dunglas
2
1.7k
テストコード文化を0から作り、変化し続けた組織
kazatohiei
2
1.5k
良いユニットテストを書こう
mototakatsu
7
2.2k
RWC 2024 DICOM & ISO/IEC 2022
m_seki
0
210
コンテナをたくさん詰め込んだシステムとランタイムの変化
makihiro
1
130
たのしいparse.y
ydah
3
120
htmxって知っていますか?次世代のHTML
hiro_ghap1
0
330
今年一番支援させていただいたのは認証系サービスでした
satoshi256kbyte
1
250
create_tableをしただけなのに〜囚われのuuid編〜
daisukeshinoku
0
240
useSyncExternalStoreを使いまくる
ssssota
6
1k
Featured
See All Featured
The Cost Of JavaScript in 2023
addyosmani
45
7k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
26
1.9k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
RailsConf 2023
tenderlove
29
940
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
656
59k
Rails Girls Zürich Keynote
gr2m
94
13k
KATA
mclloyd
29
14k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
The Art of Programming - Codeland 2020
erikaheidi
53
13k
How STYLIGHT went responsive
nonsquared
95
5.2k
A designer walks into a library…
pauljervisheath
204
24k
Transcript
-BSBWFMͷ Ξϓσ༰Λউख ʹධՁͯ͠Έͨ !LPUBNBU
ࣗݾհ
ࣗݾհ দຊଠ ·ͭͱ͜͏ͨ גࣜձࣾ4$065&3$50 ۀͷόοΫΤϯυ΄΅-BSBWFM ࣗసं͕͖ !LPUBNBU
ʗ ʗ స৬رͷ༑ਓਓΛ اۀʹհ͠ใुΛಘΒΕΔ $UP#ਓࡐհαʔϏε 4$065&3ͱ
༗ྉ৬ۀհ ਓࡐհձࣾ ϔουϋϯλʔ اۀ ٻ ৬ ऀ ༗ྉ৬ۀհ հͯ͠ใुΛಘΔʹ໔ڐ͕ඞཁ ʹ
4$065&3ͱ ا ۀ స ৬ ऀ εΧλʔ ొऀ ݸਓ͕հͯ͠ใुΛड͚औΕΔ ʹ
ཧղͷ͋Δ૬ஊ૬ख ࣌ؒΛ͔͚ͨҙࢥܾఆ͕Ͱ͖Δ ࠷దͳٻਓΛબͼԠืͰ͖Δ ࠷స৬ऀʹدΓఴͬͨհΛ࣮ݱ 4$065&3ͷར 4$065&3ͷಛ
༰ Ξοϓσʔτͷ༰ΛউखʹධՁ w ධՁ࣠ w ͓ͬײ w ࣮༻ੑ w ˑ˒ͰධՁ
3FTQPOTBCMF ϨεϙϯεΛΫϥεԽͯ͠ఆٛͰ͖Δ ˒˒˒˒ˑ use Illuminate\Contracts\Support\Responsable; class ExampleObject implements Responsable {
public function __construct($name = null) { $this->name = $name ?? 'Teapot'; } public function status() { switch(strtolower($this->name)) { case 'teapot': return 418; default: return 200; } } public function toResponse() { return response( "Hello {$this->name}", $this->status(), ['X-Person' => $this->name] ); } } w UP3FTQPOTFΛ࣮͠ ͨ3FTQPOTBCMFܕΛฦ Γʹ͢Δ͜ͱͰɺҙͷ ϨεϙϯεΛ࣮ݱͰ͖Δɻ w "1*͝ͱʹWJTJCMFઃఆ͠ ͍ͨͱ͖ͱ͔ಛघͳϨεϙ ϯεʹ͍ͨ͠ͱ͖͑Δ ͔ͳʝʁ
#MBEFJG #MBEFͷ!ؔΛಠࣗఆٛͰ͖Δ ˒˒ˑˑˑ w #MBEFJG Λ 4FSWJDF1SPWJEFSCPP U Ͱఆ͓͚ٛͯͩ͘͠Ͱ ༻Մೳ
w !ؔCMBEFͰ༻Մೳ w 1PMJDZͱͷซ༻Ͱ৭ʑ͕ Γͦ͏ɻɻʁ w CMBEFͬͯͳ͍ͱ͍Βͳ͍ use Illuminate\Support\Facades\Blade; Blade::if('admin', function () { return auth()->check() && auth()- >user()->isAdmin(); }); @admin <a href="{{ route('super.secret') }}">Secret Page</a> @else Welcome Guest. <a href="{{ route('login') }}">Login</a> @endadmin
$VTUPN7BMJEBUJPO3VMF όϦσʔγϣϯϧʔϧΛΫϥεԽͯ͠࠶ར༻Մೳʹ ˒˒˒˒ˑ w 3VMFΛ࣮ͨ͠Ϋϥε Λఆٛ͠ɺϧʔϧͷ ʹΠϯελϯεΛ͢ ͚ͩͰϧʔϧઃஔͰ͖ Δ class
CowbellValidationRule implements Rule { public function passes($attribute, $value) { return $value > 10; } public function message() { return ':attribute needs more cowbell!'; } } w ࣄۀυϝΠϯʹґଘ͠ ͨόϦσʔγϣϯΑ ͍͘·Θ͢ͷͰ༗༻
EVNQDPMMFDUJPO DPMMFDUJPOͷϝιουνΣʔϯͷ్தͰதΈΕΔΑ͏ʹ ˒ˑˑˑˑ w ίϨΫγϣϯͷ్தͰ EVNQ ೖΕΕͦͷ్த Λඪ४ग़ྗ͢Δ w EE
ͩͱFYJUͱͳΔ w ։ൃதͩͱ݁ߏ͏͔͠Ε ͳ͍͕ɺMBSBWFMUJOLFSͰ ͍ͩͿࣄΓͦ͏ɻɻ collect([1,2,3])->map(function($i){ return $i * 2; })->dump()->reject(function($i){ return $i < 3; });
1BDLBHF"VUP%JTDPWFSZ BQQQIQมߋ͠ͳͯ͘ύοέʔδ͑Δ ˒˒˒˒˒ w ύοέʔδଆͰࠨهͷΑ͏ͳ ઃఆΛDPNQPTFSKTPOʹ ॻ͍͓͚ͯͩ͘Ͱɺউखʹొ ͞ΕΔɻ w l'PPaa#BSa
a4FSWJDF1SPWJEFSJT OPUGPVOEzࠈ͔Β։์ ͞ΕΔɻɻʂ "extra": { "laravel": { "providers": [ "Foo\\Bar\\ServiceProvider" ], "aliases": { "Bar": "Foo\\Bar\\Facade" } } }
8IPPQT ؼ͖ͬͯͨ8IPPQT ˒˒˒˒˒ w ΤϥʔϋϯυϦϯάΛ͖Ε͍ ʹදࣔ w *%&༻ʹϦϑΝϨϯεΛදࣔ w ग़ྗϑΥʔϚοτΛબͰ͖
Δ +40/ 9.- 40"1 w ֦ு͕༰қ
UISPX@JGIFMQFS CPPMఆͰྫ֎͛Δϔϧύʔ ˒˒˒˒ˑ w ΄΅λΠτϧ௨ΓͰ͆͢ w &YDFQUJPO)BOEMFSͰϨ εϙϯεఆ͍ٛͯ͠Δ߹ ͑Δ͔ $foo
= true; throw_if($foo, new BarException('Foo is true')); // or throw_if($foo, BarException::class, 'Foo is true');
7BMJEBUJPOSFUVSOTSFRVFTUEBUB 7BMJEBUJPOͰఆٛͨ͠ϑΟʔϧυzͷΈzσʔλநग़ͯ͠ ฦ͢ ˒˒˒˒˒ w SFRVFTU POMZ Λ Θͳͯ͘Α͘ͳͬͨɻ w
όϦσʔγϣϯϧʔϧແ͠Ͱ σʔλΛड͚औΓ͍ͨ߹ ۭจࣈͰϧʔϧΛࢦఆ͢Δɻ w ؔ৺͕ڽॖ͞ΕΔͷͰ $data = $this->validate(request(), [ 'name' => 'required', 'price' => 'required|numeric', 'notRequiredField' => '', ]); // $data = request()->only('name', 'price', 'category_id');
'SPOUFOEQSFTFUT BSUJTBOίϚϯυͰKTϑϨʔϜϫʔΫ؆୯ઃஔ ˒ˑˑˑˑ w 3FBDU CPPUTUSBQ 7VFKTΛઃஔͰ͖ΔΑ͏ʹ w ਖ਼࠷ॳ͔͠Θͳ͍ʝ
php artisan preset react|bootstrap
.JHSBUF'SFTI$PNNBOE શςʔϒϧΛ%SPQ͔ͯ͠ΒϚΠάϨʔγϣϯ࣮ߦ ˒˒˒˒˒ w SFGSFTIͱҧ͍ϩʔϧ όοΫ͠ͳ͍ͷͰɺݱঢ়ͷ%# ঢ়گԿʹΑͬͯϚΠάϨʔ γϣϯ͕ࣦഊ͠ͳ͍ w ຊ൪%#ΛϛϥʔϦϯάͯ͠
εςʔδϯά%#Λ͍ͬͯ ΔϓϩδΣΫτͰ༗༻ php artisan migrate:fresh
&NBJM5IFNFTJO.BJMBCMFT ϝʔϧςϯϓϨʔτΛ؆୯ʹઃఆՄೳʹ ˒˒ˑˑˑ w .BJMBCMFͷΫϥεͰ UIFNFΛࢦఆͰ͖ΔΑ ͏ʹ w DPOGJH bNBSLEPXOQBUIT`
<DPOGJH bNBSLEPXOUIFNF` > ʹࢦ ఆ͞ΕͨDTTΛಡΈࠐΉ w ෳͷαʔϏεΛ࣮ߦ class SendInvoice extends Mailable { protected $theme = 'my-theme'; ... }
.BJMBCMFTSFOEFSUPCSPXTFS ϝʔϧจ໘ΛϒϥβͰ֬ೝͰ͖ΔΑ͏ʹ ˒˒˒˒˒ w 3FOEFSBCMFΛܧঝͨ͠Ϋϥε Ͱ͋ΕɺϨεϙϯεʹΠϯελ ϯε͚ͩ͢ͰϒϥβνΣοΫ Մೳʹ w ࠓ·ͰNBJMDBUDIFSͳͲͰ
ϝʔϧඈͨ͠Γ͍ͯͨ͠ͷͰɺ σβΠϯमਖ਼͍ͩͿָʹ Route::get('/demo', function () { return new App\Mail\UserWelcome(); });
WFOEPSQVCMJTI1SPWJEFSQSPNQU WFOEPSQVCMJTI࣮ߦ࣌༻͢Δ1SPWJEFSΛબ͢Δ Α͏ʹ ˒˒ˑˑˑ w WFOEPSQVCMJTI࣮ߦ࣌શ෦ QVCMJTI͞ΕΔͷΛ͙ w ։ൃ࣌ϓϥάΠϯͷνΣοΫͰ ͑Δͱࢥ͏͚Ͳɺ࣮ӡ༻࣌
UBHIPHFͰࢦఆ͢ΔͷͰɺͦΕ ΄ͲԸܙͳ͍͔ͳ͊ɻɻ
NBLJOH.PEFM'BDUPSZ NPEFMGBDUPSZΛBSUJTBOίϚϯυͰੜՄೳʹ ˒ˑˑˑˑ w ίϚϯυҰൃͰNPEFMGBDUPSZ ͕ੜՄೳ w ͨͩɺੜ͞ΕΔͷ͕ɺۭͷͷ ͳͷͰɺਖ਼SZNBOBMV GBDUPSZHFOFSBUPSͰ.PEFM
ͷGJMMBCMFΛఆͯࣗ͠ಈੜ ͢Δ΄͏͕͍উख͕͍͍ɻɻ php artisan make:factory UserFactory
·ͱΊ -BSBWFM։ൃޮˢͷόʔδϣϯ w ϩʔΧϧͰͷΈҙຯ͕͋ΔPS։ൃޮ্͛ΔΑ͏ͳΞοϓσʔ τ͕ओͩͬͨɻ w -BSBWFM͕XFC։ൃͷϑϨʔϜϫʔΫͷಓΛಥ͖ਐΜͰ͍Δҹ ͦͦͦ͏͍͏ཱ͚͚ͯͩͲ
w ٕज़తʹഁյతʹ໘ന͍Ξοϓσʔτͱݴ͏ײ͡Ͱͳ͔ͬͨʝ w -54خ͍͠ DPNQPTFSDSFBUFMBSBWFMMBSBWFM QIQBSUJTBOTFSWF ૣͬͯΈΑ͏