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
16k
モダンPHPチュートリアル (LLまつり版)
レガシーなプラクティスを捨ててモダンなコードを。
Yusuke Ando
August 24, 2013
Tweet
Share
More Decks by Yusuke Ando
See All by Yusuke Ando
CakePHP3でアプリ開発
yandod
1
350
Shimokita.Unity パーティクルでエフェクト
yandod
0
770
CakePHP3の明るい未来
yandod
1
210
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
670
Detonatorで爆発させる勉強会をした報告
yandod
0
2.4k
Mecanimでアニメーション - Shimokita.Unity
yandod
0
720
パリの街をUnityで駆ける
yandod
1
3.4k
Other Decks in Programming
See All in Programming
VisionProで部屋の明るさを反映させるシェーダーを作った話
segur
0
100
HTML/CSS超絶浅い説明
yuki0329
0
190
PHPとAPI Platformで作る本格的なWeb APIアプリケーション(入門編) / phpcon 2024 Intro to API Platform
ttskch
0
390
カンファレンス動画鑑賞会のススメ / Osaka.swift #1
hironytic
0
170
Stackless и stackful? Корутины и асинхронность в Go
lamodatech
0
1.3k
React 19でお手軽にCSS-in-JSを自作する
yukukotani
5
560
traP の部内 ISUCON とそれを支えるポータル / PISCON Portal
ikura_hamu
0
180
LLM Supervised Fine-tuningの理論と実践
datanalyticslabo
8
1.9k
いりゃあせ、PHPカンファレンス名古屋2025 / Welcome to PHP Conference Nagoya 2025
ttskch
1
170
watsonx.ai Dojo #6 継続的なAIアプリ開発と展開
oniak3ibm
PRO
0
170
盆栽転じて家具となる / Bonsai and Furnitures
aereal
0
1.8k
ecspresso, ecschedule, lambroll を PipeCDプラグインとして動かしてみた (プロトタイプ) / Running ecspresso, ecschedule, and lambroll as PipeCD Plugins (prototype)
tkikuc
2
1.8k
Featured
See All Featured
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
A Philosophy of Restraint
colly
203
16k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
Building Flexible Design Systems
yeseniaperezcruz
328
38k
Product Roadmaps are Hard
iamctodd
PRO
50
11k
Scaling GitHub
holman
459
140k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
860
Side Projects
sachag
452
42k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.3k
Git: the NoSQL Database
bkeepers
PRO
427
64k
Designing Experiences People Love
moore
139
23k
KATA
mclloyd
29
14k
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ͰΠϯετʔϧ ίʔυϦϙδτϦ͕εοΩϦ
࣭ʁ