Upgrade to Pro — share decks privately, control downloads, hide ads and more …

外部委託の立場から半ば強引にLaravelを導入した話

 外部委託の立場から半ば強引にLaravelを導入した話

Laralab vol.1 (https://laralab.connpass.com/event/65160/) で発表させていただいた資料です。

Yudai Shinnoki

September 13, 2017
Tweet

More Decks by Yudai Shinnoki

Other Decks in Programming

Transcript

  1. ൿ఻ͷλϨ •  PHP 5.3 •  MySQL 5.1 •  Smarty • 

    Shift-JISͱ૬ੑ͕ѱ͘ɺ{literal}Ͱ ғΘͳ͍ͱΤϥʔʹͳͬͨΓ͢Δ จࣈίʔυ͸Shift-JIS
  2. ൿ఻ͷλϨ •  PHP 5.3 •  MySQL 5.1 •  Smarty • 

    Shift-JISͱ૬ੑ͕ѱ͘ɺ{literal}Ͱ ғΘͳ͍ͱΤϥʔʹͳͬͨΓ͢Δ •  όʔδϣϯ؅ཧ͞Ε͍ͯͳ͍ •  ͱ͜ΖͲ͜Ζʹྺ࢙Λײ͡ΒΕΔ •  CentOSͳͷʹ/user/local/apache2ͷ ઈରύε͕ϋʔυίʔυ͞ΕͯͨΓ͢Δ จࣈίʔυ͸Shift-JIS
  3. γεςϜߏ੒ •  આಘͷ͠қ͔͞ΒɺLaravel 5.1 LTS Λબ୒ •  PHP 7.0 (7.1͡Όͳ͍ཧ༝͸ಛʹແ͍)

    •  Laravel 5.5 LTS ͕ 8/30 ʹϦϦʔε •  طଘγεςϜ͔Βஈ֊తʹҠߦ •  nginxͰURL͝ͱʹϦόʔεϓϩΩγ •  DBεΩʔϚ͕มΘΔͱطଘγεςϜͷमਖ਼ ΋ඞཁʹͳΔͷͰɺطଘγεςϜ͕ඞཁͳ͘ ͳ͔ͬͯΒDBΛݟ௚͢
  4. EloquentϞσϧͷ࣮૷ •  protected $table •  ໋໊نଇʹԊ͍ͬͯͳ͍৔߹ඞਢ •  protected $primaryKey • 

    Model::whereΛ࢖͏͚ͩͩͬͨΒ࣮͸ෆཁ •  relationを考えると設定しておいたほうが無難 •  const CREATED_AT, const UPDATED_AT •  ͲͪΒ΋ෆཁͳΒ public $timestamps = false; •  updateͷΈෆཁͳΒ public function setUpdatedAt($value) { }
  5. /config/database.php ͷจࣈίʔυઃఆ •  DBͷจࣈίʔυΛແࢹͯ͠ ’charset’ => ’utf8’ •  ͨͿΜ SET

    NAMES utf8 ͱಉ͡ޮՌ •  varcharͰ͸͏·͍͕͘͘blobͰจࣈԽ͚͢Δ •  ૉ௚ʹ’charset’ => ’sjis’ •  ιʔε͸UTF8ʹ͍ͨ͠ͷͰɺ EloquentϞσϧ͔ΒAttributeऔಘ࣌ʹม׵ •  Illuminate\Database\Eloquent\ModelΛ ܧঝͨ͠ abstract class SjisBaseModel Λ࣮૷ͯ͠ڞ௨ॲཧΛॻ͘ํ਑
  6. public function getAttribute($key) ͷ override •  ͢΂ͯͷΞΫηαʔʹڞ௨ͳॲཧΛॻ͚Δ •  ݸผʹΞΫηαʔ͕͋Δ৔߹ͦͷޙʹݺ͹ΕΔ • 

    getAttribute ʹSJIS->UTF8ม׵Λॻ͘৔߹ getFooAttribute ͸SJISͰฦ͢ඞཁ͕͋Δ(ʂ) •  protected function getAttributeFromArray Λ override ͢Δ͜ͱͰDB͔Βऔಘͨ͠σʔλ ͷΈΛม׵Ͱ͖ͨ