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を導入した話
Search
Yudai Shinnoki
September 13, 2017
Programming
0
690
外部委託の立場から半ば強引にLaravelを導入した話
Laralab vol.1 (
https://laralab.connpass.com/event/65160/
) で発表させていただいた資料です。
Yudai Shinnoki
September 13, 2017
Tweet
Share
More Decks by Yudai Shinnoki
See All by Yudai Shinnoki
AWS “““触って””” みた
shinnoki
0
110
体に馴染む開発環境 ~ghqはいいぞ~
shinnoki
0
1.7k
組織戦略と GraphQL、Hasura
shinnoki
2
4.7k
Hasura とは何者か メリット・デメリット
shinnoki
10
2.8k
TypeScript と React Hooks と GraphQL のステキな関係性
shinnoki
2
480
リリース前に知りたいネイティブのあれこれ
shinnoki
0
1.4k
Other Decks in Programming
See All in Programming
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
160
tool ディレクティブを導入してみた感想
sgash708
1
150
新世界の理解
koriym
0
140
Claude Code と OpenAI o3 で メタデータ情報を作る
laket
0
140
なぜ今、Terraformの本を書いたのか? - 著者陣に聞く!『Terraformではじめる実践IaC』登壇資料
fufuhu
4
650
Langfuseと歩む生成AI活用推進
licux
3
290
GitHub Copilotの全体像と活用のヒント AI駆動開発の最初の一歩
74th
8
3.1k
AI OCR API on Lambdaを Datadogで可視化してみた
nealle
0
170
自作OSでDOOMを動かしてみた
zakki0925224
1
1.4k
A Gopher's Guide to Vibe Coding
danicat
0
170
Google I/O recap web編 大分Web祭り2025
kponda
0
2.9k
兎に角、コードレビュー
mitohato14
0
150
Featured
See All Featured
How to Ace a Technical Interview
jacobian
279
23k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.5k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
33
2.4k
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
8
480
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
16k
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
A better future with KSS
kneath
239
17k
Code Reviewing Like a Champion
maltzj
525
40k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
15
1.6k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.8k
Art, The Web, and Tiny UX
lynnandtonic
302
21k
Transcript
֎෦ҕୗͷཱ͔Β ڧҾʹLaravelΛಋೖͨ͠ LaraLab vol.1 2017/09/13 @shibuya 21cafe
Yudai Shinnoki @konoki_nannoki Freelance Engineer ͓ͳҊ࣮݅ PHPɺΠϯϑϥɺAndroid(Java) ษڧத SwiftɺReact Native
࠷ۙͷڵຯ Architecting on AWS 21ສԁ+੫ϋʔυϧ͕ߴ͍…
Brush-UPֶͼ • LaravelΛͬͨγεςϜΛ9/4ʹެ։͠·ͨ͠ https://www.brush-up.jp
ൿͷλϨ • PHP 5.3 • MySQL 5.1 • Smarty
ൿͷλϨ • PHP 5.3 • MySQL 5.1 • Smarty •
Shift-JISͱ૬ੑ͕ѱ͘ɺ{literal}Ͱ ғΘͳ͍ͱΤϥʔʹͳͬͨΓ͢Δ จࣈίʔυShift-JIS
ൿͷλϨ • PHP 5.3 • MySQL 5.1 • Smarty •
Shift-JISͱ૬ੑ͕ѱ͘ɺ{literal}Ͱ ғΘͳ͍ͱΤϥʔʹͳͬͨΓ͢Δ • όʔδϣϯཧ͞Ε͍ͯͳ͍ • ͱ͜ΖͲ͜Ζʹྺ࢙Λײ͡ΒΕΔ • CentOSͳͷʹ/user/local/apache2ͷ ઈରύε͕ϋʔυίʔυ͞ΕͯͨΓ͢Δ จࣈίʔυShift-JIS
None
γεςϜߏ • આಘͷ͠қ͔͞ΒɺLaravel 5.1 LTS Λબ • PHP 7.0 (7.1͡Όͳ͍ཧ༝ಛʹແ͍)
• Laravel 5.5 LTS ͕ 8/30 ʹϦϦʔε • طଘγεςϜ͔Βஈ֊తʹҠߦ • nginxͰURL͝ͱʹϦόʔεϓϩΩγ • DBεΩʔϚ͕มΘΔͱطଘγεςϜͷमਖ਼ ඞཁʹͳΔͷͰɺطଘγεςϜ͕ඞཁͳ͘ ͳ͔ͬͯΒDBΛݟ͢
্࣮ͷ՝ ① طଘDBͱͷ࿈ܞ
EloquentϞσϧͷ࣮ • protected $table • ໋໊نଇʹԊ͍ͬͯͳ͍߹ඞਢ • protected $primaryKey •
Model::whereΛ͏͚ͩͩͬͨΒ࣮ෆཁ • relationを考えると設定しておいたほうが無難 • const CREATED_AT, const UPDATED_AT • ͲͪΒෆཁͳΒ public $timestamps = false; • updateͷΈෆཁͳΒ public function setUpdatedAt($value) { }
ෳछྨͷEloquentϞσϧͰϧʔϓ͍ͨ͠ • Illuminate\Database\Eloquent\Collectionʹ ෳclassΛಥͬࠐΜͰͳ͍ • EloquentϞσϧʹڞ௨ͷΞΫηαʔΛ࣮͢Δ • has-Oneͳ͕ؔଟஈʹͳ͍ͬͯΔ߹ ҰஈʹͳΔΑ͏ʹΞΫηαʔͰΤΠϦΞε ͓ͯ͘͠ͱUndefined
ErrorΛҙࣝ͠ͳ͍ͰࡁΉ
্࣮ͷ՝ ② Shift-JISରԠ
/config/database.php ͷจࣈίʔυઃఆ • DBͷจࣈίʔυΛແࢹͯ͠ ’charset’ => ’utf8’ • ͨͿΜ SET
NAMES utf8 ͱಉ͡ޮՌ • varcharͰ͏·͍͕͘͘blobͰจࣈԽ͚͢Δ • ૉʹ’charset’ => ’sjis’ • ιʔεUTF8ʹ͍ͨ͠ͷͰɺ EloquentϞσϧ͔ΒAttributeऔಘ࣌ʹม • Illuminate\Database\Eloquent\ModelΛ ܧঝͨ͠ abstract class SjisBaseModel Λ࣮ͯ͠ڞ௨ॲཧΛॻ͘ํ
None
public function getAttribute($key) ͷ override • ͯ͢ͷΞΫηαʔʹڞ௨ͳॲཧΛॻ͚Δ • ݸผʹΞΫηαʔ͕͋Δ߹ͦͷޙʹݺΕΔ •
getAttribute ʹSJIS->UTF8มΛॻ͘߹ getFooAttribute SJISͰฦ͢ඞཁ͕͋Δ(ʂ)
public function getAttribute($key) ͷ override • ͯ͢ͷΞΫηαʔʹڞ௨ͳॲཧΛॻ͚Δ • ݸผʹΞΫηαʔ͕͋Δ߹ͦͷޙʹݺΕΔ •
getAttribute ʹSJIS->UTF8มΛॻ͘߹ getFooAttribute SJISͰฦ͢ඞཁ͕͋Δ(ʂ) • protected function getAttributeFromArray Λ override ͢Δ͜ͱͰDB͔Βऔಘͨ͠σʔλ ͷΈΛมͰ͖ͨ
None
ݸਓతʹ ͍͍ͱײͨ͡ͱ͜Ζ
BladeʹૉͷPHPίʔυ͕ॻ͚Δ • ࠔͬͨΒͱΓ͋͑ͣ<?php ?> Ͱॻ͚͍͍ • ίϯϙʔωϯτͬΆ͘@include Ͱ͖Δ
BladeʹૉͷPHPίʔυ͕ॻ͚Δ • ࠔͬͨΒͱΓ͋͑ͣ<?php ?> Ͱॻ͚͍͍ • ίϯϙʔωϯτͬΆ͘@include Ͱ͖Δ ͪΐͬͱෳࡶͳॲཧ ͉
ςϯϓϨʔτ
ιʔείʔυ͕͍͍͢ʢؾ͕͢Δʣ • PHPStorm Ͱߋʹշద • ʮLaravelɹPHPStormʯͱ͔Ͱݕࡧ͢Δͱ ηοτΞοϓͷใ͕Ͱͯ͘Δ • ܕએݴΛ͏ͱΰϦΰϦͱิͯ͘͠ΕΔ •
ઌड़ͷgetAttributeFromArray ͜ͷ͓ӄͰؾ͚ͮͨ
·ͱΊ • ্࣮ͷ੍͕ଟ͍߹Ͱɺ LaravelͳΒॊೈʹରԠͰ͖Δͱײͨ͡ • DBͷݟ͍ͩ͠ͿָʹͳΓͦ͏ • Laravel 5.5 LTSҠߦʹ͍ͭͯͷใ͕
͋ͬͨΒڭ͍͑ͯͩ͘͞