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
640
外部委託の立場から半ば強引に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
91
体に馴染む開発環境 ~ghqはいいぞ~
shinnoki
0
1.6k
組織戦略と GraphQL、Hasura
shinnoki
2
4.6k
Hasura とは何者か メリット・デメリット
shinnoki
10
2.7k
TypeScript と React Hooks と GraphQL のステキな関係性
shinnoki
2
430
リリース前に知りたいネイティブのあれこれ
shinnoki
0
1.3k
Other Decks in Programming
See All in Programming
CQRS+ES の力を使って効果を感じる / Feel the effects of using the power of CQRS+ES
seike460
PRO
0
120
talk-with-local-llm-with-web-streams-api
kbaba1001
0
180
tidymodelsによるtidyな生存時間解析 / Japan.R2024
dropout009
1
770
20年もののレガシープロダクトに 0からPHPStanを入れるまで / phpcon2024
hirobe1999
0
410
Fibonacci Function Gallery - Part 1
philipschwarz
PRO
0
210
fs2-io を試してたらバグを見つけて直した話
chencmd
0
230
快速入門可觀測性
blueswen
0
340
Beyond ORM
77web
3
380
ソフトウェアの振る舞いに着目し 複雑な要件の開発に立ち向かう
rickyban
0
890
Symfony Mapper Component
soyuka
2
730
開発者とQAの越境で自動テストが増える開発プロセスを実現する
92thunder
1
180
선언형 UI에서의 상태관리
l2hyunwoo
0
150
Featured
See All Featured
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
2
170
For a Future-Friendly Web
brad_frost
175
9.4k
VelocityConf: Rendering Performance Case Studies
addyosmani
326
24k
Building Applications with DynamoDB
mza
91
6.1k
Mobile First: as difficult as doing things right
swwweet
222
9k
KATA
mclloyd
29
14k
Navigating Team Friction
lara
183
15k
Thoughts on Productivity
jonyablonski
67
4.4k
Imperfection Machines: The Place of Print at Facebook
scottboms
266
13k
Git: the NoSQL Database
bkeepers
PRO
427
64k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
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Ҡߦʹ͍ͭͯͷใ͕
͋ͬͨΒڭ͍͑ͯͩ͘͞