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

ランダムデータをPHPで作る

 ランダムデータをPHPで作る

PHPカンファレンス2015 LT

Kenichiro Kishida

October 03, 2015
Tweet

More Decks by Kenichiro Kishida

Other Decks in Programming

Transcript

  1. w0QFO4PVSDF (1-W https://github.com/benkeen/generatedata wϥϯμϜσʔλΛੜ੒͢Δπʔϧ Tool for generation randomize data w1)1

     .Z42-  Ͱಈ࡞ wίϛϡχςΟʹΑΔ%PDLFS 7BHSBOU؀ڥ͕͋Δ exists runtime environment of Docker or Vagrant
  2. wҰ౓ఆٛͨ͠ϧʔϧ͸อଘͯ͠࠶ར༻ Մೳ the difinition can save to database w8FC6*͚ͩ͡Όͳ͘3&45"1*΋͋ Δ

    have REST API not only Web UI w೔ຊޠͷݴޠϑΝΠϧͳ͍ but, not have japanese language file :-(
  3. w1)1ϓϩάϥϚ޲͚ for PHP programer w೔ຊޠͷݴޠϑΝΠϧ͕͋Δ it have japanese language file

    wσʔλλΠϓͷ਺͕ HFOFSBUFEBUBDPNΑΓଟ͍ it have many data types more than generatedata.com wओʹ஋Λੜ੒͢ΔͨΊͷϥΠϒϥϦ it focus to generate fake value
  4. w1)1ϓϩάϥϚ޲͚ for PHP programer w಺෦Τϯδϯ͸'BLFS use Faker for generation randomize

    data wಠࣗʹมߋ͍ͨ͠ΧϥϜ্͚ͩॻ͖Մ ೳ be able to overwrite, you want it wݱ࣌఺͸$BLF1)1$BLF1)1 ͷΈରԠ ORM adaptors, CakePHP2, CakePHP3 currentry
  5. /** Fabricate Xxxxx Adaptor */ class XxxxFabricateAdaptor extends AbstractFabricateAdaptor {

    public function getModel($modelName) { $model = new FabricateModel($modelName); // εΩʔϚ৘ใ͔ΒϞσϧΦϒδΣΫτΛੜ੒͢Δ return $model; } public function create($modelName, $attributes, $recordCount) { // ORM΁σʔλΛอଘ͢ΔॲཧΛॻ͘ return $entities; } public function build($modelName, $data) { // ORMͷΤϯςΟςΟΫϥεΛੜ੒͢Δ return $entity; } }