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チュートリアル (LLまつり版)
Search
Yusuke Ando
August 24, 2013
Programming
37
15k
モダンPHPチュートリアル (LLまつり版)
レガシーなプラクティスを捨ててモダンなコードを。
Yusuke Ando
August 24, 2013
Tweet
Share
More Decks by Yusuke Ando
See All by Yusuke Ando
CakePHP3でアプリ開発
yandod
1
330
Shimokita.Unity パーティクルでエフェクト
yandod
0
750
CakePHP3の明るい未来
yandod
1
200
Testing your app with Selenium on Travis CI
yandod
8
3.1k
Testing your app with Selenium on Travis CI
yandod
0
130
Inputで入力を扱う
yandod
0
660
Detonatorで爆発させる勉強会をした報告
yandod
0
2.4k
Mecanimでアニメーション - Shimokita.Unity
yandod
0
710
パリの街をUnityで駆ける
yandod
1
3.4k
Other Decks in Programming
See All in Programming
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
1.1k
文化が生産性を作る
jimpei
2
490
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
6
230
推しの夫に恋のGPS「ときメーター」#M5Stack #IoT #M5JPTour2024
riyu
0
220
Micro Frontends for Java Microservices - dev2next 2024
mraible
PRO
0
190
Vue :: Better Testing 2024
up1
1
370
AWS CDKを用いたセキュアなCI/CDパイプラインの構築 / Build a secure CI/CD pipeline using AWS CDK
seike460
PRO
3
500
Pydantic x Database API:turu-pyの開発
yassun7010
1
470
Beyond the RuboCop Defaults
koic
2
480
[KR] Server Driven Compose With Firebase
skydoves
1
120
Cloud Adoption Frameworkにみる組織とクラウド導入戦略(縮小版)
tomokusaba
1
170
◯◯エンジニアになった理由
gessy0129
PRO
0
600
Featured
See All Featured
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
32k
Producing Creativity
orderedlist
PRO
341
39k
How STYLIGHT went responsive
nonsquared
94
5.1k
BBQ
matthewcrist
84
9.2k
Building Your Own Lightsaber
phodgson
102
6k
A Tale of Four Properties
chriscoyier
155
22k
Web development in the modern age
philhawksworth
205
10k
Designing for Performance
lara
604
68k
The Straight Up "How To Draw Better" Workshop
denniskardys
231
130k
Automating Front-end Workflow
addyosmani
1365
200k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
Visualization
eitanlees
143
15k
Transcript
MMNBUTVSJ!ZBOEP Modern PHP Tutorial d1)1࣌ͷࣝΛࣺͯɺ1)1࣌d
ZBOEP $BOEZ$BOFQIQ ʮ࠙ձϐβൃΞϓϦʯ
1)1ରԠ1BB4 $IFGͰ"84Λࣗಈߏஙɺߋ৽ "84ͱಉ͡ڥΛίετʹ ࣌ؒ༗ਓࢹΦϓγϣϯ 44)TVEPՄೳ͔ͭαϙʔτ༗
1)1 8FCʹಛԽͨ͠εΫϦϓτݴޠ 8FCαʔϏεΛத৺ʹ෯͍ར༻ ඇΤϯδχΞͷར༻ऀଟ͍ ؒҧͬͨϓϥΫςΟε·͍ͬͯΔ
ΞδΣϯμ جૅࣝ ؒҧͬͨϓϥΫςΟε ϞμϯͳϓϥΫςΟε ͬͯΈΑ͏
جૅࣝ
ใͷ୳͠ํ ॳ৺ऀ͚ͷॻ੶๛ ެࣜϚχϡΞϧͷಡΈํ͕େࣄ தʙ্ڃऀ͚ϑϨʔϜϫʔΫ༷ʑ 1)15IF3JHIU8BZ
None
ॻ੶બͼ ༰͕ݹ͘ͳΔ ݱʹ͍ΔஶऀɺϥΠλʔઐͷஶऀ αϯϓϧίʔυͷηΩϡϦςΟ ݁ہԿ͔ͷ߹ΘٕͤʹͳΔ
QIQOFU
QIQOFU ެࣜϚχϡΞϧ ෆஅͷྗͰຊޠԽ͞Ε͍ͯΔ جຊతʹ࠷৽ͷ1)1ʹ४ڌ KQQIQOFUͱ͍͏ϛϥʔ͋Δ Կނ͔ σβΠϯ͕ϦχϡʔΞϧ༧ఆ
৽σβΠϯ
ҠߦΨΠυ
ऴྃͨ͠όʔδϣϯ 1)1 ʹऴྃࡁΈ 1)1 ʹऴྃࡁΈ 1)1 ʹऴྃࡁΈ
1)1 ʹऴྃࡁΈ 1)1 ʹऴྃ༧ఆ
ݱߦόʔδϣϯ 1)1 ໊લۭؒ Ϋϩʔδϟ
Ԇ੩తଋറ -4# 1)1 "SSBZ4IPSU4ZOUBY USBJU ϏϧτΠϯαʔό 1)1 δΣωϨʔλ pOBMMZ
ϙΠϯτ 1)1Ҏ͔߱ͭͯ1)1ͱݺΕͯ ͍ͨػೳΛؚΜͰ͍Δ 1)1த৺ͷݱͰ͋ͬͯ1)1Ҏ߱ ͷػೳͷ׆༻ेʹਐΜͰ͍ͳ͍
Ϟμϯ1)1 ݹ͍ϓϥΫςΟεΛഇ͠ɺ ਖ਼͍͠1)1Λॻ͜͏
ϨΨγʔ1)1ɺɹۦஞͯ͠Δʜ ͜ͷੈ͔ΒʜɹҰߦʜΒͣ
ؒҧͬͨϓϥΫςΟε photo by toyohara
ʑͷؒҧ͍ JOD $3 -' SFHJTUFS@HMPCBMT TBGF@NPEF NBHJD@RVPUF ! WBS
NZTRM@DPOOFDU SFRVJSF@PODF 1&"3 ؆୯ Nڃ ෳࡶ Nڃ ෳࡶ Nڃ ෳࡶ Nڃ
ϑΝΠϧ JOD $3 -'
ϑΝΠϧͷ࠷ޙͷ লུͰ͖Δ ͷޙͷۭന͕͔͍ͬ )551ϔομͷ੍ޚෆೳɺṖͷۭߦ େྔͷϑΝΠϧʹฆΕΔͱհ
Ṗͷۭߦ <?php //৭ʑͳίʔυ $view->render(); ?>
͜ͷԿॲ͔ʹۭߦ͕ʜ
͜ΕͰΑ͍ <?php //৭ʑͳίʔυ $view->render(); QIQͷ෦ͷۭߦग़ྗ͞Εͳ͍
JOD$3 -' ֦ுࢠJODͷϑΝΠϧʹϥΠϒϥϦΛ ஔ͘ѱश ίʔυ࿙Ӯͷةݥ͋Γ վߦίʔυ-'ʹ౷Ұ͖͢
1)1ͷҨ࢈ SFHJTUFS@HMPCBMT TBGF@NPEF NBHJD@RVPUF@HQD SVOUJNF ഇࢭ͞ΕΔͷͰೋͱ͍͚ͬͯͳ͍
ෆશͳ001ͷ໊ ! WBS
! Τϥʔ੍ԋࢉࢠ ͔ͭͯྫ֎͕ଘࡏ͠ͳ͔ͬͨ σόοάΛࠔʹ͢Δհͳଘࡏ దʹίʔσΟϯά͢Εແ༻ͷଘࡏ
WBS QVCMJDQSJWBUFͳͲ͕ແ͔ͬͨࠒͷଘࡏ QVCMJDQSJWBUFΛهड़͢Δ͖ TUBUJDదʹઃఆ͢Δ
໌ࣔతͳࢀর͠ ͔ͭͯϝϞϦઅͷςΫχοΫ ݱࡏৗʹࢀরʹͳΔͷͰෆཁ ͋͑ͯίϐʔ͍ͨ࣌͠ʹDMPOF
1)1 <?php class A { var $foo = 1;
} $obj =& new A(); $obj2 =& $obj; $obj2->foo = 2; echo $obj->foo;
ෆཁ 1)1 <?php class A { public $foo = 1;
} $obj = new A(); $obj2 = $obj; $obj2->foo = 2; echo $obj->foo;
ݹ͍ϥΠϒϥϦ NZTRM@DPOOFDU SFRVJSF@PODF 1&"3ͷޡ༻
NZTRM@DPOOFDU ݹདྷΑΓΘΕ͖ͯͨؔ 1)1͔Βඇਪɺഇࢭ༧ఆ NZTRMJ@DPOOFDU1%0Λ͏
SFRVJSF@PODF ผϑΝΠϧͷϥΠϒϥϦͷಡΈࠐΈ ͱʹ͔͋͘Ε͜ΕಡΈࠐΈ·͘Γ͕ͪ BVUPMPBEػߏ͕ग़དྷͨͷͰෆཁʹ
1&"3 ོ͔ͭͯΛތͬͨϥΠϒϥϦ܊ ݫ֨ͳެࣜνϟωϧ ݱଘ͢ΔϑϨʔϜϫʔΫͷૅ Πϯετʔϥʔ͕͍ʹ͍͘ ίϐʔ͞Εվม͞Εɺߋ৽ෆೳʹ
1&"3 ิ ݱࡏ1)16OJU4NBSUZͳͲ1&"3ϕʔ εͷϥΠϒϥϦ׆ൃ ઃఆ1ZSVTͳͲʹΑΔରॲ๏͋Δ ਖ਼͘͠ར༻͠ɺదʹӡ༻͞Ε͍ͯΕ ͳ͍ ޡ༻͞ΕΔ͜ͱ
͋ͳͨͷίʔυʹ͜͏͍ ͬͨ༰͕ଟ͍ͱةݥ
ϨΨγʔ1)1ɺɹۦஞͯ͠Δʜ ͜ͷੈ͔ΒʜɹҰߦʜΒͣ
ϞμϯͳϓϥΫςΟε
None
1)15IF3JHIU8BZ 4MJN'SBNFXPSLͷ࡞ऀ+PTIࢯ͕ൃىਓ 1)1ͷϕετϓϥΫςΟε (JU)VC্Ͱ֤ݴޠʹ༁͞Εͨ ͜ͷ༰Λक͍ͬͯΕϞμϯ
ͷϓϥΫςΟε ͡Ίʹ ίʔσΟϯάελΠϧ ݴޠ༷ ґଘؔͷཧ ίʔσΟϯάʹؔ͢Δ׳श σʔλϕʔε ηΩϡϦςΟ ςετ ֤छαʔόʔͷσϓϩΠ
Ωϟογϡ ใݯ ίϛϡχςΟ
͡Ίʹ 1)1Ҏ߱Λ͏ .BD049ͷ1)1ݹ͍IPNFCSFX 8JOEPXT৭ʑ͋Γ͗͢ 7BHSBOUศར
7BHSBOU 7JSUVBM#PYΛΠϯετʔϧ 7BHSBOUΛΠϯετʔϧ ͖ͳ7BHSBOUpMFΛDMPOF WBHSBOUVQ શʹઃఆ͞ΕͨԾϚγϯ͕ىಈ
ίʔσΟϯάελΠϧ 143143143 1)1$PEF4OJ⒎FS 1)1$PEJOH4UBOEBSET'JYFS
None
େࣄͳͱ͜Ζ ϑΝΠϧ໊ɺύε ΠϯσϯτɺϒϨʔεͷҐஔ 1)14UPSNͳͲͷ*%&ͰݕࠪՄೳ
ݴޠ༷ͷϙΠϯτ 001ແ໊໊ؔલۭؒτϨΠτ Ϋϩʔδϟ ϝλϓϩάϥϛϯά 41-$-* 9%FCVH
DMBTTͷڭࣨ
ґଘؔͷཧ $PNQPTFSϓϩδΣΫτґଘؔ 1&"3γεςϜશମͷґଘؔ ࠷৽൛ͷߋ৽੬ऑੑνΣοΫ ϥΠϒϥϦQBDLBHJTUͰ୳ͤΑ͍
$PNQPTFS DVSMTIUUQTHFUDPNQPTFSPSH JOTUBMMFScQIQ DPNQPTFSKTPO DPNQPTFSJOTUBMM SFRVJSFbWFOEPSBVUPMPBEQIQ` SFRVJSF͜Ε͚ͩ
ίʔσΟϯά جຊ ࣌ࠁ%BUF5JNF σβΠϯύλʔϯ'BDUPSZ4JOHMFUPOϑ ϩϯτίϯτϩʔϥ.7$ ྫ֎ॲཧ
جຊ ൺֱԋࢉࢠ JGFMTF TXJUDI γϯάϧΫΦʔτɺμϒϧΫΦʔτ ࡾ߲ԋࢉࢠ
σʔλϕʔε 1%0 NZTRM@DPOOFDU ഇࢭ༧ఆ 1%0൚༻త͔ͭߴػೳ όΠϯυΛઈର͏
όΠϯυ
ηΩϡϦςΟ ύεϫʔυͷϋογϡQBTTXPSE@IBTI σʔλͷϑΟϧλϦϯά αχλΠζ όϦσʔγϣϯ 3FHJTUFS(MPCBMT1)1Ͱഇࢭ
݁ɿಙؙຊΛങ͏
ςετ Ϣχοτςετ1)16OJU ػೳςετ4FMFOJVN ৼۦಈ։ൃ#%%#FIBU1)14QFD
None
σϓϩΠ 1BB4 OHJOYQIQGQNলϝϞϦ "QBDIFNPE@QIQ 1IJOH$BQJTUSBOP$IFG $* +FOLJOT 5FBNDJUZ
None
None
Ωϟογϡ όΠτίʔυΩϟογϡ "1$9$BDIF;FOE0QUJNJ[FS8JO$BDIF ΦϒδΣΫτΩϟογϡ "1$.FNDBDIF3FEJT
5IF3JHIU8BZ த্ڃऀʹͱͬͯͨΓલͷ༰ ͷࢼߦࡨޡͷੵͷ݁Ռ ॾࣄ͋ͬͯɺैͬͯଛແ͍
ͬͯΈΑ͏ʂ
࡞Δͷ 7BHSBOUͰಈ͘ $PNQPTFSͰϥΠϒϥϦΛಋೖ 5XJUUFS͔Βใऔಘ
7BHSBOU 7JSUVBM#PY7BHSBOU IUUQTHJUIVCDPNZBOEPEQIQ OHJOYWBHSBOUTBNQMF HJUDMPOF WBHSBOUVQ
DPNQPTFSKTPO WBHSBOUTTI DEWBHSBOU@EBUBTBOECPY DPNQPTFSKTPOΛهड़͢Δ ࣗಈͰखಈͰͰ͖Δ
DPNQPTFSKTPO { "name": "llmatsuri/sample", "authors": [ { "name": "yando", "email":
"
[email protected]
" } ], "require": { "dg/twitter-php": "*" } }
DPNQPTFSKTPO ΄͍͠ϥΠϒϥϦΛݕࡧͯ͠ࢦఆ͢Δ 8FCͰίϚϯυͰݕࡧͰ͖Δ ࣮1&"3ΠϯετʔϧͰ͖Δ ࠷ޙʹDPNQPTFSJOTUBMMͰ·ͱΊͯ%-
DPNQPTFSJOTUBMM vagrant@precise64:/vagrant_data$ composer install Loading composer repositories with package information
Installing dependencies (including require-dev) - Installing dg/twitter-php (v3.1) Loading from cache Writing lock file Generating autoload files
JOTUBMM͢Δͱ DPNQPTFSMPDL͕ੜ͞ΕΔ WFOEPSҎԼʹϥΠϒϥϦ͕%-͞ΕΔ WFOEPSҎԼʹΦʔτϩʔμ͕ஔ
༻ޙ
BVUPMPBE BVUPMPBEQIQ͚ͩΛSFRVJSF͢Δ ඞཁͳ࣌ʹ֤ΫϥεΛࣗಈͰಡΈࠐΉ ೋͱSFRVJSF@PODFΛॻ͔ͳ͍ ϑϨʔϜϫʔΫ͕ಡΈࠐΉ߹͋Δ
JOEFYQIQ <?php require_once 'vendor/autoload.php'; $twitter = new Twitter(); ͜Ε͚ͩͰ5XJUUFSΫϥεΛࣗಈతʹ WFOEPSEHUXJUUFSQIQTSD͔ΒಡΈࠐΉʂ
Τϥʔʁ 5XJUUFSΫϥείϯγϡʔϚΩʔͱ ίϯγϡʔϚγʔΫϨοτ͕ඞཁΒ͍͠
EFWUXJUUFSDPNBQQT αΠϯΞοϓ ΞϓϦΛ࡞ ੜ͞ΕͨΩʔใΛίϐͬͯ͏
औಘ <?php require_once 'vendor/autoload.php'; $twitter = new Twitter( 'aaaa', 'bbbb',
'cccc', 'dddd' ); $info = $twitter->loadUserInfo('yando'); var_dump($info->status->text);
͓͓ʂ
͋ͱ ϥΠϒϥϦΛDPNQPTFSKTPOՃ DPNQPTFSVQEBUFͰߋ৽ WFOEPSΛίϛοτ͠ͳ͍ σϓϩΠ࣌ʹJOTUBMMͰWFOEPSΛ࠶ੜ
͞Βʹ 143Λक͍ͬͯΕࣗ࡞ΫϥεͰ BVUPMPBEʹରԠͰ͖Δ 1&"3ͳͲDPNQPTFSͰΠϯετʔϧ ίʔυϦϙδτϦ͕εοΩϦ
࣭ʁ