Link
Embed
Share
Beginning
This slide
Copy link URL
Copy link URL
Copy iframe embed code
Copy iframe embed code
Copy javascript embed code
Copy javascript embed code
Share
Tweet
Share
Tweet
Slide 1
Slide 1 text
$",&1)1ͰֶͿ ܧଓతΠϯςάϨʔγϣϯϋϯζΦϯ ։ൃฤ @PHPΧϯϑΝϨϯεԬ 2015/6/27
Slide 2
Slide 2 text
WHO? • Θͨͳ͔ͣͻΖ(@kaz_29) • ߹ಉձࣾ decr (decr.jp) • PHP(CakePHP)ͰWebΞϓϦ։ൃ • Πϯϑϥߏஙɾӡ༻ • iOSΞϓϦ։ൃ #beer #iosdev #cakephp #cat #camp #golf #chef #vagrant
Slide 3
Slide 3 text
WHO?
Slide 4
Slide 4 text
ಈ࡞ڥ
Slide 5
Slide 5 text
BeHat • ϏϔΠϏΞ(ৼ)ۦಈ։ൃ (BDD:Behaviour Driven Development) • ετʔϦʔϕʔεͷςεςΟϯάϑϨʔϜϫʔΫ
Slide 6
Slide 6 text
BeHat 'FBUVSFͷهड़ྫ
Slide 7
Slide 7 text
BeHat 'FBUVSFͷ࣮ߦྫ
Slide 8
Slide 8 text
BeHat #%%։ൃϓϩηε
Slide 9
Slide 9 text
࠷ॳͷεϓϦϯτ͕ ऴΘΔॴἬϫʔϓ͠·͢
Slide 10
Slide 10 text
࠷ॳͷεϓϦϯτ͕ ྃͨ͠ঢ়ଶΛ࡞ host $ vagrant ssh develop $ cd /var/www/application/current/app $ git merge origin/step2 $ composer install --dev
Slide 11
Slide 11 text
DATABASEΛMigration
Slide 12
Slide 12 text
DATABASEΛMigration $ cd /var/www/application/current/app $ Console/cake Migrations.migration run all
Slide 13
Slide 13 text
http://192.168.33.10/posts
Slide 14
Slide 14 text
UnitTest $ cd /var/www/application/current/app $ Console/cake Test app AllTests
Slide 15
Slide 15 text
No content
Slide 16
Slide 16 text
StoryTest $ cd /var/www/application/current/app $ Console/cake Bdd.story
Slide 17
Slide 17 text
No content
Slide 18
Slide 18 text
JenkinsʹࠐΜͰ͍͖·͢ʂ
Slide 19
Slide 19 text
ͦͷલʹ… $ git update-index --add --chmod=+x Console/cake $ git add -u $ git commit -m “cakeίϚϯυʹ࣮ߦݖΛ༩” $ git push origin master
Slide 20
Slide 20 text
BUILDπʔϧΛಋೖ — phingΛಋೖ $ cd /var/www/application/current/app $ composer require --dev "phing/phing:~2.8"
Slide 21
Slide 21 text
PHINGͷઆ໌
Slide 22
Slide 22 text
BUILDπʔϧΛಋೖ — मਖ਼Λίϛοτ $ git add composer.json composer.lock $ git commit -m 'PhingΛՃ'
Slide 23
Slide 23 text
BUILDͷઃఆ /var/www/application/current/build.xml
Slide 24
Slide 24 text
BUILDπʔϧΛಋೖ — ϏϧυΛ࣮ߦ $ cd /var/www/application/current $ app/Vendor/bin/phing
Slide 25
Slide 25 text
BUILDπʔϧΛಋೖ — मਖ਼Λίϛοτ $ git add build.xml $ git commit -m ‘ϏϧυϑΝΠϧΛՃ' $ git push origin master
Slide 26
Slide 26 text
BUILDπʔϧΛಋೖ
Slide 27
Slide 27 text
BUILDπʔϧΛಋೖ
Slide 28
Slide 28 text
BUILDπʔϧΛಋೖ cd ${WORKSPACE}/app composer install --dev cd ${WORKSPACE} app/Vendor/bin/phing -logger phing.listener.DefaultLogger
Slide 29
Slide 29 text
ϏϧυΛ࣮ߦʂ
Slide 30
Slide 30 text
UnitTest݁ՌΛදࣔ
Slide 31
Slide 31 text
UnitTest݁ՌΛදࣔ͢Δ — build.xmlΛमਖ਼
Slide 32
Slide 32 text
UnitTest݁ՌΛදࣔ͢Δ — मਖ਼Λίϛοτ $ git add build.xml $ git commit -m 'Ϣχοτςετͷ݁ՌΛϑΝΠϧ ʹग़ྗ' $ git push origin master
Slide 33
Slide 33 text
UnitTest݁ՌΛදࣔ͢Δ
Slide 34
Slide 34 text
UnitTest݁ՌΛදࣔ͢Δ app/reports/unittest.xml
Slide 35
Slide 35 text
UnitTest݁ՌΛදࣔ͢Δ
Slide 36
Slide 36 text
UnitTest݁ՌΛදࣔ͢Δ app/reports/ app/reports/coverage.xml मਖ਼ͨ͠Βอଘͯ͠Ϗϧυ࣮ߦ νΣοΫ͢Δ
Slide 37
Slide 37 text
UnitTest݁ՌΛදࣔ͢Δ
Slide 38
Slide 38 text
UnitTest݁ՌΛදࣔ͢Δ ConfigσΟϨΫτϦͷΧόϨοδ͕͍ʂ
Slide 39
Slide 39 text
UnitTest݁ՌΛදࣔ͢Δ — app/phpunit.xmlΛमਖ਼(ΧόϨοδͷআ֎ઃఆΛՃ) Plugin Test Vendor Config/bootstrap Config/database.php <-- ͜͜·ͰՃ -->
Slide 40
Slide 40 text
UnitTest݁ՌΛදࣔ͢Δ — मਖ਼Λίϛοτ $ git add app/phpunit.xml $ git commit -m 'ΧόϨοδআ֎ରΛՃ' $ git push origin master
Slide 41
Slide 41 text
UnitTest݁ՌΛදࣔ͢Δ ΧΠθϯͨ͠ʂ
Slide 42
Slide 42 text
Behatͷ݁ՌΛදࣔ͢Δ — build.xmlΛमਖ਼ … …
Slide 43
Slide 43 text
Behatͷ݁ՌΛදࣔ͢Δ — मਖ਼Λίϛοτ $ git add build.xml $ git commit -m 'BehatςετΛՃ' $ git push origin master
Slide 44
Slide 44 text
Behatͷ݁ՌΛදࣔ͢Δ app/reports/*.xml ʹमਖ਼ मਖ਼ͨ͠Βอଘͯ͠Ϗϧυ࣮ߦ
Slide 45
Slide 45 text
Behatͷ݁ՌΛදࣔ͢Δ
Slide 46
Slide 46 text
੩తղੳͷઃఆΛ͢Δ
Slide 47
Slide 47 text
੩తղੳͷઃఆΛ͢Δ $ cd /var/www/application/current/app $ composer require --dev "cakephp/cakephp-codesniffer:0.1.*" $ composer require --dev "phpmd/phpmd:2.*" $ composer require --dev "sebastian/phpcpd:2.*"
Slide 48
Slide 48 text
੩తղੳͷઃఆΛ͢Δ — मਖ਼Λίϛοτ $ git add composer.json composer.lock $ git commit -m 'ΠϯεϖΫγϣϯπʔϧͷՃ' $ git push origin master
Slide 49
Slide 49 text
੩తղੳͷઃఆΛ͢Δ — build.xmlΛमਖ਼(1) … …
Slide 50
Slide 50 text
੩తղੳͷઃఆΛ͢Δ — build.xmlΛमਖ਼(2) - PHPCodeSnifferͷઃఆΛՃ …
Slide 51
Slide 51 text
੩తղੳͷઃఆΛ͢Δ — build.xmlΛमਖ਼(3) - PHPMDͷઃఆΛՃ …
Slide 52
Slide 52 text
੩తղੳͷઃఆΛ͢Δ — build.xmlΛमਖ਼(4) - PHPCPDͷઃఆΛՃ …
Slide 53
Slide 53 text
੩తղੳͷઃఆΛ͢Δ — मਖ਼Λίϛοτ $ git add build.xml $ git commit -m 'ΠϯεϖΫγϣϯͷ࣮ߦΛՃ' $ git push origin master
Slide 54
Slide 54 text
੩తղੳͷઃఆΛ͢Δ app/reports/checkstyle.xml app/reports/phpmd.xml app/reports/phpcpd.xml
Slide 55
Slide 55 text
੩తղੳͷઃఆΛ͢Δ MigrationͱSchemaʹܯࠂ
Slide 56
Slide 56 text
੩తղੳͷઃఆΛ͢Δ — build.xmlΛमਖ਼(5) - PHPMDͷআ֎σΟϨΫτϦՃ …
Slide 57
Slide 57 text
੩తղੳͷઃఆΛ͢Δ — मਖ਼Λίϛοτ $ git add build.xml $ git commit -m 'PMDͷআ֎σΟϨΫτϦΛՃ' $ git push origin master
Slide 58
Slide 58 text
੩తղੳͷઃఆΛ͢Δ ΧΠθϯͨ͠ʂ
Slide 59
Slide 59 text
υΩϡϝϯτΛੜ͢Δ — build.xmlΛमਖ਼(1) … …
Slide 60
Slide 60 text
υΩϡϝϯτΛੜ͢Δ $ git add build.xml $ git commit -m 'υΩϡϝϯτੜͷ࣮ߦΛՃ' $ git push origin master
Slide 61
Slide 61 text
υΩϡϝϯτΛੜ͢Δ
Slide 62
Slide 62 text
υΩϡϝϯτΛੜ͢Δ ՃΛԡͯ͠ҎԼͷΑ͏ʹઃఆ app/reports/doc/ index.html API Documentation
Slide 63
Slide 63 text
υΩϡϝϯτΛੜ͢Δ
Slide 64
Slide 64 text
υΩϡϝϯτΛੜ͢Δ app/Model/Post.phpʹҎԼͷ༷ʹίϝϯτΛՃ * */ class Post extends AppModel { …
Slide 65
Slide 65 text
υΩϡϝϯτΛੜ͢Δ app/Model/Post.phpʹҎԼͷ༷ʹίϝϯτΛՃ class Post extends AppModel { /** * Ұཡදࣔ࣌ͷλΠτϧʹ༻͢ΔΧϥϜ໊ * * @var string */ public $displayField = 'title'; /** * όϦσʔγϣϯϧʔϧ * * @var array */ public $validate = [
Slide 66
Slide 66 text
υΩϡϝϯτΛੜ͢Δ $ git add app/Model/Post.php $ git commit -m 'DocBlockίϝϯτΛՃ' $ git push origin master मਖ਼ͨ͠Βอଘͯ͠Ϗϧυ࣮ߦ
Slide 67
Slide 67 text
υΩϡϝϯτΛੜ͢Δ
Slide 68
Slide 68 text
ຊ൪ڥʹDEPLOY͢Δ
Slide 69
Slide 69 text
ຊ൪ڥʹDEPLOY͢Δ $ vagrant ssh deploy $ ssh-keygen อଘॴ,ύεϑϨʔζೖྗ(ۭͰվߦͰ) $ cat ~/.ssh/id_rsa.pub ެ։伴Λίϐʔ
Slide 70
Slide 70 text
ຊ൪ڥʹDEPLOY͢Δ Add deploy keyΛΫϦοΫͯ͠ެ։伴ΛՃ
Slide 71
Slide 71 text
ຊ൪ڥʹDEPLOY͢Δ $ cd /var/www/application/current $ mkdir deploy $ cd deploy $ cap install CapistranoͷDeployεΫϦϓτͷͻͳܗΛ࡞
Slide 72
Slide 72 text
ຊ൪ڥʹDEPLOY͢Δ deploy/config/deploy/production.php 'localhost', 'MYSQL_USERNAME' => 'webapp', 'MYSQL_PASSWORD' => 'passw0rd', 'MYSQL_DB_NAME' => 'blog', 'MYSQL_PREFIX' => '', 'debug' => 0, ], function() { }); ຊ൪αʔόʔ༻ͷઃఆϑΝΠϧΛՃ
Slide 73
Slide 73 text
ຊ൪ڥʹDEPLOY͢Δ $ cd /var/www/application/current/deploy/config/deploy $ vim production.rb server '192.168.33.200', roles: %w{web app db}, user: 'vagrant', ssh_options: { password: fetch(:password) }, cake_env: "production", app_config:'production.php', group: 'vagrant' Deployઌͷઃఆ
Slide 74
Slide 74 text
ຊ൪ڥʹDEPLOY͢Δ $ cd /var/www/application/current/deploy/ $ vim reploy.rb — 5ߦͷϦϙδτϦURLΛ֤ࣗमਖ਼ set :repo_url, '
[email protected]
:phpcibook/blogapp.git' # (2) DeployεΫϦϓτΛमਖ਼ ϑΝΠϧͷৄࡉ stypi_ deploy.rbࢀর
Slide 75
Slide 75 text
ຊ൪ڥʹDEPLOY͢Δ $ cd /var/www/application/current/deploy/ $ cap production deploy Please enter Server password: (): vagrant
Slide 76
Slide 76 text
։ൃฤ Fin @kaz_29