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

WordPressローカル開発環境をつくろう — WP-CLI + Composer —

WordPressローカル開発環境をつくろう — WP-CLI + Composer —

Takashi Kitajima

March 06, 2017
Tweet

More Decks by Takashi Kitajima

Other Decks in Programming

Transcript

  1. ΩλδϚλΧγ !JOD   ϑϦʔϥϯε ʙ 
 8FCσβΠφʔϓϩάϥϚʔ  8PSE1SFTTϓϥάΠϯ


    .881'PSNɺ4NBSU$VTUPN'JFMETʜ  8PSE1SFTTςʔϚ
 )BCBLJSJɺ.JNJ[VLVʜ  4BTT4UZMVT$44ϑϨʔϜϫʔΫ
 #BTJT
  2. w 8PSE1SFTTαΠτίΞ ϓϥάΠϯ ςʔϚ w ·Δ͝ͱ(JUϦϙδτϦͰ؅ཧ
 
 ˠطʹ؅ཧ͞Ε͍ͯΔίΞ΍ϓϥάΠϯͷίʔυ·Ͱ
 ɹೋॏ؅ཧͯ͠͠·͏͜ͱʹͳΔ w

    ຊ౰͸ࣗ෼ͷॻ͍ͨίʔυ͚ͩ؅ཧ͍ͨ͠
 
 ˠίΞ΍ϓϥάΠϯ΋όʔδϣϯͰಈ࡞͕มΘΔͷͰ
 ɹ؅ཧ͠ͳ͍Θ͚ʹ͸͍͔ͳ͍
  3. جຊతͳDPNQPTFSίϚϯυ # ύοέʔδΛΠϯετʔϧ (ྫ: Symfony Yaml Component) $ composer require

    symfony/yaml # ։ൃ؀ڥͰ͚ͩ࢖͏ύοέʔδΛΠϯετʔϧ (ྫ: phpunit) $ composer require --dev phpunit/phpunit # composer.jsonɺcomposer.lock ʹهड़͞ΕͨύοέʔδΛΠϯετʔϧ $ composer install # ύοέʔδΛશ෦ߋ৽ $ composer update # ಛఆͷύοέʔδ͚ͩΛߋ৽ (ྫ: phpunit) $ composer update phpunit/phpunit
  4. ϓϥάΠϯͷ௥Ճ $ composer require wpackagist-plugin/<Πϯετʔϧ͢ΔϓϥάΠϯͷεϥοά> 
 # MW WP Form

    ΛΠϯετʔϧ͢Δྫ $ composer require wpackagist-plugin/mw-wp-form # Smart Custom Fields ΛΠϯετʔϧ͢Δྫ $ composer require wpackagist-plugin/smart-custom-fields
  5. ςʔϚͷ௥Ճ $ composer require wpackagist-theme/<Πϯετʔϧ͢ΔςʔϚͷεϥοά> # Lightning ΛΠϯετʔϧ͢Δྫ $ composer

    require wpackagist-theme/lightning # Habakiri ΛΠϯετʔϧ͢Δྫ $ composer require wpackagist-theme/habakiri
  6. ;ͭ͏ʹDPNQPTFSίϚϯυͰ0, # શ෦ߋ৽ $ composer update # ಛఆͷϓϥάΠϯ͚ͩߋ৽ $ composer

    update wpackagist-plugin/mw-wp-form # ಛఆͷςʔϚ͚ͩߋ৽ $ composer update wpackagist-theme/habakiri
  7. Α͘࢖͏81$-*ίϚϯυ # ΠϯετʔϧࡁΈͷςʔϚΛ༗ޮԽ $ wp theme activate twentyseventeen # σʔλϕʔε಺จࣈྻͷஔ׵

    (γϦΞϥΠζରԠ) $ wp search-replace http://127.0.0.1:8080 http://example.com # σʔλϕʔεͷΠϯϙʔτɾΤΫεϙʔτ $ wp db import/export
  8. ϋϯζΦϯɹ؆୯ͳϓϥάΠϯΛͭͬͯ͘ΈΑ͏ # ϓϥάΠϯͷ਽ܗΛੜ੒ɾ༗ޮԽ # ϢχοτςετɺίʔσΟϯάن໿४ڌςετɺEditorConfig ΋ੜ੒͞ΕΔ ! $ wp scaffold

    plugin sample-plugin —activate http://localhost:9000/wp-admin # γϣʔτίʔυ [phper] Λ௥Ճ͢ΔϓϥάΠϯΛͭͬͯ͘ΈΑ͏ https://gist.github.com/inc2734/158b59217bee19a2db9b1ba3692a8a6d
  9. ϋϯζΦϯɹ؆୯ͳϓϥάΠϯΛͭͬͯ͘ΈΑ͏ # ϢχοτςετΛ͔͍ͯΈΑ͏ https://gist.github.com/inc2734/6c0920516d9fb909e9b8d1e89c8bff77 # ϢχοτςετΛ࣮ߦͯ͠ΈΑ͏ # PHPUnit ͷΠϯετʔϧ $

    composer require --dev phpunit/phpunit # PHPUnit Λ૸ΒͤΔҰ࣌ςετ؀ڥͷੜ੒ $ bash ./bin/install-wp-tests.sh wordpress_test root 'hogehoge' localhost latest # PHPUnit ࣮ߦ $ /path/to/wp-content/mu-plugins/vendor/phpunit/phpunit/phpunit