Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
CIハンズオン@PHPカンファレンス福岡-開発
Search
Kaz Watanabe
June 27, 2015
Programming
190
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
CIハンズオン@PHPカンファレンス福岡-開発
Kaz Watanabe
June 27, 2015
More Decks by Kaz Watanabe
See All by Kaz Watanabe
開発エンジニアが取り組む DevSecOps ~ GitHub Enterprise × Azure での実践~
kaz29
0
46
Greenは本当にGreenか? - B/GデプロイとAPI自動テストで安心デプロイ
kaz29
1
200
CI/CD/IaC 久々に0から環境を作ったらこうなりました
kaz29
1
510
開発エンジニアが実践するDevSecOps
kaz29
0
170
PHPCon福岡2024-Azureもなかなかいいですよ.pdf
kaz29
2
390
Azure Container Apps + Bicep 〜 こんな感じで運用しています
kaz29
3
1.3k
20220908_フロントエンドパフォーマンス改善.pdf
kaz29
2
200
PHP製のPodCast配信用WebアプリをReact+Next.jsなSSGで作り直してみた話
kaz29
3
720
バックエンドエンジニアの私がお勧めする SPAフロントエンド開発環境
kaz29
6
6.3k
Other Decks in Programming
See All in Programming
モデルのリファクタリングが難しいと思ったら、そもそも複雑だったのはビジネス仕様だった ? / is-the-business-domain-the-real-complexity
hatsu38
0
430
選挙速報を多くのユーザーへ 届ける Live Activities 設計
hamayokokuririn
0
190
iOSDC Japan 2026 - Swiftで作って学ぼう!データベース自作入門
kaseken
2
420
Omarchy Tokyo やると聞いて UMPC 買ってセットアップしてきた
mtsmfm
0
200
JRuby: Past, Present, and Future
headius
0
220
速習iPhone Duo対応
yuukiw00w
2
920
Intent as Code
shoppingjaws
6
1.1k
テストを司るデーモンに会いに行く 〜隔離した仮想マシンでテストを通すまで〜
h1d3mun3
1
600
JAWS-UG 東京支部が始める、JAWS-UG支部コラボ / JAWS-UG lunchtime LT Collaboration
y0hgi
0
170
KiroのSpecで「五目並べ」を作ってみる
satoshi256kbyte
1
320
C#の現在地 進化の歴史と、AI時代の.NET Everywhere
neuecc
5
4.7k
setup-vp GitLab対応の裏側
naokihaba
0
140
Featured
See All Featured
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
310
Evolving SEO for Evolving Search Engines
ryanjones
0
300
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
380
Navigating Weather and Climate Data
rabernat
0
540
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
330
The Cult of Friendly URLs
andyhume
79
7k
The World Runs on Bad Software
bkeepers
PRO
72
12k
How Software Deployment tools have changed in the past 20 years
geshan
2
34k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.5k
Color Theory Basics | Prateek | Gurzu
gurzu
1
480
How to Talk to Developers About Accessibility
jct
2
560
Transcript
$",&1)1ͰֶͿ ܧଓతΠϯςάϨʔγϣϯϋϯζΦϯ ։ൃฤ @PHPΧϯϑΝϨϯεԬ 2015/6/27
WHO? • Θͨͳ͔ͣͻΖ(@kaz_29) • ߹ಉձࣾ decr (decr.jp) • PHP(CakePHP)ͰWebΞϓϦ։ൃ •
Πϯϑϥߏஙɾӡ༻ • iOSΞϓϦ։ൃ #beer #iosdev #cakephp #cat #camp #golf #chef #vagrant
WHO?
ಈ࡞ڥ
BeHat • ϏϔΠϏΞ(ৼ)ۦಈ։ൃ (BDD:Behaviour Driven Development) • ετʔϦʔϕʔεͷςεςΟϯάϑϨʔϜϫʔΫ
BeHat 'FBUVSFͷهड़ྫ
BeHat 'FBUVSFͷ࣮ߦྫ
BeHat #%%։ൃϓϩηε
࠷ॳͷεϓϦϯτ͕ ऴΘΔॴἬϫʔϓ͠·͢
࠷ॳͷεϓϦϯτ͕ ྃͨ͠ঢ়ଶΛ࡞ host $ vagrant ssh develop $ cd /var/www/application/current/app
$ git merge origin/step2 $ composer install --dev
DATABASEΛMigration
DATABASEΛMigration $ cd /var/www/application/current/app $ Console/cake Migrations.migration run all
http://192.168.33.10/posts
UnitTest $ cd /var/www/application/current/app $ Console/cake Test app AllTests
None
StoryTest $ cd /var/www/application/current/app $ Console/cake Bdd.story
None
JenkinsʹࠐΜͰ͍͖·͢ʂ
ͦͷલʹ… $ git update-index --add --chmod=+x Console/cake $ git add
-u $ git commit -m “cakeίϚϯυʹ࣮ߦݖΛ༩” $ git push origin master
BUILDπʔϧΛಋೖ — phingΛಋೖ $ cd /var/www/application/current/app $ composer require --dev
"phing/phing:~2.8"
PHINGͷઆ໌
BUILDπʔϧΛಋೖ — मਖ਼Λίϛοτ $ git add composer.json composer.lock $ git
commit -m 'PhingΛՃ'
BUILDͷઃఆ <?xml version="1.0" encoding="UTF-8"?> <!-- Phing build config file. @link
http://www.phing.info/ --> <project name="blogapp" default="build"> <!-- Properties --> <property name="basedir" value="${phing.dir}" /> <property name="appdir" value="${basedir}/app" /> <property name="logdir" value="${appdir}/tmp/logs" /> <!-- Build(1) --> <target name="build" depends="prepare,caketest"/> <!-- Prepare(2) --> <target name="prepare" description="Prepare for build"> <exec dir="${appdir}" executable="${appdir}/Console/cake" output="${logdir}/migration.log" checkreturn="true"> <arg line="migrations.migration" /> <arg line="run" /> <arg line="all" /> </exec> </target> <!-- CakePHP unit test with PHPUnit(3) --> <target name="caketest" description="Run CakePHP unit tests with PHPUnit"> <exec dir="${appdir}" executable="${appdir}/Console/cake" output="${logdir}/caketest.log" checkreturn="true"> <arg line="test" /> <arg line="app" /> <arg line="AllTests" /> </exec> </target> </project> /var/www/application/current/build.xml
BUILDπʔϧΛಋೖ — ϏϧυΛ࣮ߦ $ cd /var/www/application/current $ app/Vendor/bin/phing
BUILDπʔϧΛಋೖ — मਖ਼Λίϛοτ $ git add build.xml $ git commit
-m ‘ϏϧυϑΝΠϧΛՃ' $ git push origin master
BUILDπʔϧΛಋೖ
BUILDπʔϧΛಋೖ
BUILDπʔϧΛಋೖ cd ${WORKSPACE}/app composer install --dev cd ${WORKSPACE} app/Vendor/bin/phing -logger
phing.listener.DefaultLogger
ϏϧυΛ࣮ߦʂ
UnitTest݁ՌΛදࣔ
UnitTest݁ՌΛදࣔ͢Δ — build.xmlΛमਖ਼ <target name="caketest" description="Run CakePHP unit tests with
PHPUnit"> <exec dir="${appdir}" executable="${appdir}/Console/cake" output="${logdir}/caketest.log" checkreturn="true"> <arg line="test" /> <!-- ͔͜͜Β --> <arg line="--log-junit=${appdir}/reports/unittest.xml" /> <arg line="--coverage-html=${appdir}/reports" /> <arg line="--coverage-clover=${appdir}/reports/ coverage.xml" /> <!-- ͜͜·ͰՃ --> <arg line="app" /> <arg line="AllTests" /> </exec> </target>
UnitTest݁ՌΛදࣔ͢Δ — मਖ਼Λίϛοτ $ git add build.xml $ git commit
-m 'Ϣχοτςετͷ݁ՌΛϑΝΠϧ ʹग़ྗ' $ git push origin master
UnitTest݁ՌΛදࣔ͢Δ
UnitTest݁ՌΛදࣔ͢Δ app/reports/unittest.xml
UnitTest݁ՌΛදࣔ͢Δ
UnitTest݁ՌΛදࣔ͢Δ app/reports/ app/reports/coverage.xml मਖ਼ͨ͠Βอଘͯ͠Ϗϧυ࣮ߦ νΣοΫ͢Δ
UnitTest݁ՌΛදࣔ͢Δ
UnitTest݁ՌΛදࣔ͢Δ ConfigσΟϨΫτϦͷΧόϨοδ͕͍ʂ
UnitTest݁ՌΛදࣔ͢Δ — app/phpunit.xmlΛमਖ਼(ΧόϨοδͷআ֎ઃఆΛՃ) <phpunit> <filter> <blacklist> <directory suffix=".php">Plugin</directory> <directory suffix=".php">Test</directory>
<directory suffix=".php">Vendor</directory> <!-- ͔͜͜Β --> <directory suffix=".php">Config/bootstrap</directory> <file>Config/database.php</file> <-- ͜͜·ͰՃ --> </blacklist> </filter> </phpunit>
UnitTest݁ՌΛදࣔ͢Δ — मਖ਼Λίϛοτ $ git add app/phpunit.xml $ git commit
-m 'ΧόϨοδআ֎ରΛՃ' $ git push origin master
UnitTest݁ՌΛදࣔ͢Δ ΧΠθϯͨ͠ʂ
Behatͷ݁ՌΛදࣔ͢Δ — build.xmlΛमਖ਼ … <target name="build" depends="prepare,caketest,behat"/> … <!-- ͔͜͜Β
--> <target name="behat" description="Run CakePHP acceptance test with Behat"> <exec command="find ${appdir}/tmp -type d -print | xargs chmod 777" escape="false" /> <exec dir="${appdir}" executable="${appdir}/Console/cake" output="${logdir}/behat.log" checkreturn="true"> <arg line="Bdd.story" /> <arg line="--format=junit" /> <arg line="--out=${appdir}/reports" /> </exec> </target> <!-- ͜͜·ͰՃ -->
Behatͷ݁ՌΛදࣔ͢Δ — मਖ਼Λίϛοτ $ git add build.xml $ git commit
-m 'BehatςετΛՃ' $ git push origin master
Behatͷ݁ՌΛදࣔ͢Δ app/reports/*.xml ʹमਖ਼ मਖ਼ͨ͠Βอଘͯ͠Ϗϧυ࣮ߦ
Behatͷ݁ՌΛදࣔ͢Δ
੩తղੳͷઃఆΛ͢Δ
੩తղੳͷઃఆΛ͢Δ $ 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.*"
੩తղੳͷઃఆΛ͢Δ — मਖ਼Λίϛοτ $ git add composer.json composer.lock $ git
commit -m 'ΠϯεϖΫγϣϯπʔϧͷՃ' $ git push origin master
੩తղੳͷઃఆΛ͢Δ — build.xmlΛमਖ਼(1) … <!-- Properties --> <property name="basedir" value="${phing.dir}"
/> <property name="appdir" value="${basedir}/app" /> <property name="logdir" value="${appdir}/tmp/logs" /> <!-- vendorbindir Ճ --> <property name="vendorbindir" value="${appdir}/Vendor/bin" /> <!-- Build --> <target name="build" depends="prepare,caketest,behat,phpcs,phpmd,phpcpd"/> …
੩తղੳͷઃఆΛ͢Δ — build.xmlΛमਖ਼(2) - PHPCodeSnifferͷઃఆΛՃ … <target name="phpcs" description="Find coding
standard violations using PHP_CodeSniffer."> <exec dir="${basedir}" executable="${vendorbindir}/phpcs" output="$ {logdir}/phpcs.log"> <arg line="--config-set" /> <arg line="installed_paths" /> <arg line="${appdir}/Vendor/cakephp/cakephp-codesniffer" /> </exec> <exec dir="${basedir}" executable="${vendorbindir}/phpcs" output="$ {logdir}/phpcs.log"> <arg line="--ignore=Test,Vendor,Plugin" /> <arg line="--report=checkstyle" /> <arg line="--report-checkstyle=${appdir}/reports/checkstyle.xml" /> <arg line="--standard=CakePHP" /> <arg line="--extensions=php" /> <arg line="${appdir}" /> </exec> </target>
੩తղੳͷઃఆΛ͢Δ — build.xmlΛमਖ਼(3) - PHPMDͷઃఆΛՃ … <target name="phpmd" description="Perform project
mess detection using PHPMD"> <exec dir="${basedir}" executable="${vendorbindir}/phpmd" output="${logdir}/phpmd.log"> <arg line="${appdir}" /> <arg line="xml" /> <arg line="codesize,unusedcode,design,naming" /> <arg line="--exclude ${appdir}/Test,${appdir}/Vendor,$ {appdir}/Plugin" /> <arg line="--reportfile ${appdir}/reports/phpmd.xml" /> </exec> </target>
੩తղੳͷઃఆΛ͢Δ — build.xmlΛमਖ਼(4) - PHPCPDͷઃఆΛՃ … <target name="phpcpd" description="Perform project
mess detection using PHPMD"> <exec dir="${basedir}" executable="${vendorbindir}/phpcpd" output="${logdir}/phpcpd.log"> <arg line="--exclude Vendor" /> <arg line="--exclude Plugin" /> <arg line="--exclude webroot" /> <arg line="--log-pmd ${appdir}/reports/phpcpd.xml" /> <arg line="--names *.php,*.cpt" /> <arg line="${appdir}" /> </exec> </target>
੩తղੳͷઃఆΛ͢Δ — मਖ਼Λίϛοτ $ git add build.xml $ git commit
-m 'ΠϯεϖΫγϣϯͷ࣮ߦΛՃ' $ git push origin master
੩తղੳͷઃఆΛ͢Δ app/reports/checkstyle.xml app/reports/phpmd.xml app/reports/phpcpd.xml
੩తղੳͷઃఆΛ͢Δ MigrationͱSchemaʹܯࠂ
੩తղੳͷઃఆΛ͢Δ — build.xmlΛमਖ਼(5) - PHPMDͷআ֎σΟϨΫτϦՃ … <target name="phpmd" description="Perform project
mess detection using PHPMD"> <exec dir="${basedir}" executable="${vendorbindir}/phpmd" output="${logdir}/phpmd.log"> <arg line="${appdir}" /> <arg line="xml" /> <arg line="codesize,unusedcode,design,naming" /> <!-- ͜͜ʹઃఆΛՃ(,${appdir}/Config/Migration,${appdir}/Config/Schema) --> <arg line="--exclude ${appdir}/Test,${appdir}/Vendor,$ {appdir}/Plugin,${appdir}/Config/Migration,${appdir}/Config/Schema" /> <!- ͜͜·Ͱ --> <arg line="--reportfile ${appdir}/reports/phpmd.xml" /> </exec> </target>
੩తղੳͷઃఆΛ͢Δ — मਖ਼Λίϛοτ $ git add build.xml $ git commit
-m 'PMDͷআ֎σΟϨΫτϦΛՃ' $ git push origin master
੩తղੳͷઃఆΛ͢Δ ΧΠθϯͨ͠ʂ
υΩϡϝϯτΛੜ͢Δ — build.xmlΛमਖ਼(1) … <target name="build" depends=“prepare,caketest,behat,phpcs,phpmd,phpcpd,phpdoc"/> … <!—- ҎԼΛՃ
—> <target name="phpdoc" description="Generate Application Documentation using phpDocumentor"> <exec dir="${basedir}" executable="phpdoc" output="${logdir}/phpdoc.log" checkreturn="true"> <arg line="run" /> <arg line="-t ${appdir}/reports/doc" /> <arg line="-d ${appdir}/" /> <arg line="-e php" /> <arg line="-i ${appdir}/Vendor/,${appdir}/Plugin/,${appdir}/Test/,$ {appdir}/Config/" /> <arg line="-p" /> </exec> </target>
υΩϡϝϯτΛੜ͢Δ $ git add build.xml $ git commit -m 'υΩϡϝϯτੜͷ࣮ߦΛՃ'
$ git push origin master
υΩϡϝϯτΛੜ͢Δ
υΩϡϝϯτΛੜ͢Δ ՃΛԡͯ͠ҎԼͷΑ͏ʹઃఆ app/reports/doc/ index.html API Documentation
υΩϡϝϯτΛੜ͢Δ
υΩϡϝϯτΛੜ͢Δ app/Model/Post.phpʹҎԼͷ༷ʹίϝϯτΛՃ <?php App::uses('AppModel', 'Model'); /** * Post Model *
* ϒϩάهࣄ༻ϞσϧͰ͢ * * @copyright php_ci_book * @link https://github.com/phpcibook/blogapp/blob/master/app/Model/Post.php * @since 1.0 * @auther ࡞ऀͷ໊લ <
[email protected]
> * */ class Post extends AppModel { …
υΩϡϝϯτΛੜ͢Δ app/Model/Post.phpʹҎԼͷ༷ʹίϝϯτΛՃ class Post extends AppModel { /** * Ұཡදࣔ࣌ͷλΠτϧʹ༻͢ΔΧϥϜ໊
* * @var string */ public $displayField = 'title'; /** * όϦσʔγϣϯϧʔϧ * * @var array */ public $validate = [
υΩϡϝϯτΛੜ͢Δ $ git add app/Model/Post.php $ git commit -m 'DocBlockίϝϯτΛՃ'
$ git push origin master मਖ਼ͨ͠Βอଘͯ͠Ϗϧυ࣮ߦ
υΩϡϝϯτΛੜ͢Δ
ຊ൪ڥʹDEPLOY͢Δ
ຊ൪ڥʹDEPLOY͢Δ $ vagrant ssh deploy $ ssh-keygen อଘॴ,ύεϑϨʔζೖྗ(ۭͰվߦͰ) $ cat
~/.ssh/id_rsa.pub ެ։伴Λίϐʔ
ຊ൪ڥʹDEPLOY͢Δ Add deploy keyΛΫϦοΫͯ͠ެ։伴ΛՃ
ຊ൪ڥʹDEPLOY͢Δ $ cd /var/www/application/current $ mkdir deploy $ cd deploy
$ cap install CapistranoͷDeployεΫϦϓτͷͻͳܗΛ࡞
ຊ൪ڥʹDEPLOY͢Δ deploy/config/deploy/production.php <?php Environment::configure('production', true, [ 'MYSQL_DB_HOST' => 'localhost', 'MYSQL_USERNAME'
=> 'webapp', 'MYSQL_PASSWORD' => 'passw0rd', 'MYSQL_DB_NAME' => 'blog', 'MYSQL_PREFIX' => '', 'debug' => 0, ], function() { }); ຊ൪αʔόʔ༻ͷઃఆϑΝΠϧΛՃ
ຊ൪ڥʹ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ઌͷઃఆ
ຊ൪ڥʹ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ࢀর
ຊ൪ڥʹDEPLOY͢Δ $ cd /var/www/application/current/deploy/ $ cap production deploy Please enter
Server password: (): vagrant
։ൃฤ Fin @kaz_29