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
340
Shimokita.Unity パーティクルでエフェクト
yandod
0
760
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
720
パリの街をUnityで駆ける
yandod
1
3.4k
Other Decks in Programming
See All in Programming
subpath importsで始めるモック生活
10tera
0
340
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
130
Modular Monolith Monorepo ~シンプルさを保ちながらmonorepoのメリットを最大化する~
yuisakamoto
9
1.5k
Outline View in SwiftUI
1024jp
1
350
シェーダーで魅せるMapLibreの動的ラスタータイル
satoshi7190
1
480
WebAssembly Unleashed: Powering Server-Side Applications
chrisft25
0
450
카카오페이는 어떻게 수천만 결제를 처리할까? 우아한 결제 분산락 노하우
kakao
PRO
0
120
EMになってからチームの成果を最大化するために取り組んだこと/ Maximize team performance as EM
nashiusagi
0
100
初めてDefinitelyTypedにPRを出した話
syumai
0
440
ペアーズにおけるAmazon Bedrockを⽤いた障害対応⽀援 ⽣成AIツールの導⼊事例 @ 20241115配信AWSウェビナー登壇
fukubaka0825
6
2.1k
ふかぼれ!CSSセレクターモジュール / Fukabore! CSS Selectors Module
petamoriken
0
150
2024/11/8 関西Kaggler会 2024 #3 / Kaggle Kernel で Gemma 2 × vLLM を動かす。
kohecchi
5
980
Featured
See All Featured
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
A better future with KSS
kneath
238
17k
BBQ
matthewcrist
85
9.3k
Keith and Marios Guide to Fast Websites
keithpitt
409
22k
Mobile First: as difficult as doing things right
swwweet
222
8.9k
Thoughts on Productivity
jonyablonski
67
4.3k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
A designer walks into a library…
pauljervisheath
204
24k
Six Lessons from altMBA
skipperchong
27
3.5k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
506
140k
4 Signs Your Business is Dying
shpigford
180
21k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
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ͰΠϯετʔϧ ίʔυϦϙδτϦ͕εοΩϦ
࣭ʁ