Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
自作PHPライブラリをリファクタリングした / Refactoring library
Search
howyi
December 21, 2018
Programming
120
0
Share
自作PHPライブラリをリファクタリングした / Refactoring library
社内勉強会で発表したスライドです。
ライブラリ:
https://github.com/howyi/conv
howyi
December 21, 2018
More Decks by howyi
See All by howyi
Go+gRPCで作った次世代店舗の裏側
howyi
1
1.7k
GraphQLを活用するツールやライブラリ / graphql-libraries
howyi
0
110
GraphQLの紹介 / graphql-introduction
howyi
0
86
サーバレスアーキテクチャでSlackBotを作る / serverless-slackbot
howyi
0
88
Amplifyの紹介/amplify-introduction
howyi
0
100
AWS認定を受けた話 / AWS CERTIFIED
howyi
0
89
PhpStormの設定晒す / Customizing PhpStorm
howyi
0
120
ClickUpで始める進捗管理 / ClickUp
howyi
0
520
Other Decks in Programming
See All in Programming
Spec Driven Development | AI Summit Lisbon
danielsogl
PRO
0
150
不変条件と整合性境界—ビジネスが決める設計判断と実現パターン / Invariants and Consistency Boundaries
nrslib
13
3.4k
inferと仲良くなる10分間
ryokatsuse
1
360
権限チェックの一貫性を型で守る TypeScript による多層防御
mnch
4
1.1k
Modding RubyKaigi for Myself
yui_knk
0
880
[2026年度第1回ORセミナー] 計画最適化ベンチャーと競技プログラミング人材
terryu16
0
240
TypeScriptだけでAIエージェントを作る フロント・エージェント・インフラのフルスタック実践
har1101
6
1.3k
Copilot CLI の継戦能力を高める コンテキスト管理
nozomutu
1
1.2k
ReactとSvelteのその先、Ripple-TS / Beyond React and Svelte: Ripple-TS
ssssota
3
2k
The Arts and Crafts of Work in the AI Era — Toward Mastery in Software Development
kuranuki
1
710
ユニットテストの先へ:テスト技法で要求・仕様を整理するJava開発実践 / Beyond_Unit_Testing_Practical_Java_Development_Techniques_for_Organizing_Requirements_and_Specifications
shimashima35
0
350
作って学ぶ、 JSX (TSX) ランタイムの基本
syumai
7
1.5k
Featured
See All Featured
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
How to Think Like a Performance Engineer
csswizardry
28
2.6k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.3k
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
160
Java REST API Framework Comparison - PWX 2021
mraible
34
9.3k
How Software Deployment tools have changed in the past 20 years
geshan
0
34k
Practical Orchestrator
shlominoach
191
11k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
2
4k
Leo the Paperboy
mayatellez
7
1.8k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
280
Building Applications with DynamoDB
mza
96
7.1k
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
310
Transcript
ࣗ࡞1)1ϥΠϒϥϦΛϦϑΝΫλϦϯάͨ͠ IPXZJ
ԿͷϥΠϒϥϦΛϦϑΝΫλϦϯά͔ͨ͠ https://github.com/howyi/conv ϚΠάϨʔγϣϯΫΤϦࣗಈੜϥΠϒϥϦ
ԿނϦϑΝΫλ͔ͨ͠ • MySQL5.7ʹରԠ͢Δ͜ͱʹͳͬͨ • MySQL5.6લఏͷΫΤϦੜͩͬͨͨΊɺ5.7ݻ༗ػೳ͕ೖΕΒΕͳ͔ͬͨ • मਖ਼͠Α͏ͱࢥͬͨΒࠜຊ͔Β͞ͳ͍ͱ͍͚ͳ͔ͬͨ ͍ͭͰ͔ͩΒ৭ʑͦ͏
ͬͨ͜ͱ
namespaceͷมߋ • ϕϯμ໊ΛؚΊΔΑ͏ʹͨ͠ Conv/Hoge -> Howyi/Conv/Hoge • composer.jsonͰͷΦʔτϩʔμن͕PSR-0ͩͬͨͷͰɺPSR-4ʹͨ͠
phpcsͷಋೖ • PSR12 • దʹॻ͖͗ͯͨ͢ͷͰमਖ਼͕େมͩͬͨ
makefileΛফͨ͠ composer scriptʹมߋʢ͔ͤͬ͘composerଆʹػೳ͕͋ΔͷͰʣ test: @vendor/bin/phpunit stan: @vendor/bin/phpstan analyse -l 7
-c phpstan.neon src "scripts": { "test": "phpunit", "stan": "phpstan analyse -l 7 src", } Makefile $ make test $ make stan composer.json $ composer test $ composer stan
ςετ༻SQLΛผϦϙδτϦʹΓग़͠ • ৭ʑͳύλʔϯͷSQLΛ༻ҙ͢Δඞཁ͕͋ΔͨΊɺςετ༻SQL͕ଟ͍ • composer require ~ Ͱ͜ͷςετ༻SQL·ͰΞϓϦʹΈࠐ·ΕΔͷͳΜͱͳ͘ؾ࣋ͪѱ͍ • packagistʹ্͛ͣɺcomposer.jsonͰผϦϙδτϦΛࢦఆ͠ɺrequire-dev͍ͯ͠Δ
"repositories": [ { "type": "vcs", "url": "https://github.com/howyi/conv-test-suite.git", "no-api": true } ],
ෳόʔδϣϯDBʹରԠͰ͖ΔΑ͏ߏͷมߋ ۩ମతʹ Structure͕ʮσʔλϕʔεͷදݱʯʮΫΤϦൃߦʯ ͷ2ͭͷΛ͍࣋ͬͯͨͷͰ ɺ ʮΫΤϦൃߦʯΛDriverΫϥεʢ৽نʣͷʹมߋͨ͠ DriverΫϥεDBͷόʔδϣϯʹΑͬͯΓସ͑ΒΕΔ
ෳόʔδϣϯDBʹରԠͨ͠ςετڥ • docker-composeͰରԠόʔδϣϯͷ ίϯςφΛཱͯΔ • phpunitͰɺෳDBʹରͯ͠ಉ͡ςε τΛ࣮ߦͰ͖ΔΑ͏ʹ • docker-compose upͰDBߏங+ςετ
࣮ߦ·Ͱߦ͏
ෳόʔδϣϯDBʹରԠͨ͠CIڥ ରԠલͱେ͖ͳҧ͍ͳ͘ɺมΘͬͨ෦ ʮTravisCI͕docker-composeͰςετΛ࣮ߦ͢Δ༻ʹͳͬͨʯͷΈ TravisCIͰಈ͘ίϯςφ෦͔ΒcoverallsʹΧόϨοδΛ͍͛ͯΔ
͓ΘΓ Photo by 1.Shane Stagner on Unsplash 12.Viviana Rishe on
Unsplash