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 5.4 / Introduction of PHP 5.4
Search
Sotaro Karasawa
March 27, 2012
Technology
1
4.5k
入門 PHP 5.4 / Introduction of PHP 5.4
PHP勉強会@東京 #58 発表資料です。
http://d.hatena.ne.jp/sotarok/20120328/1332864411
Sotaro Karasawa
March 27, 2012
Tweet
Share
More Decks by Sotaro Karasawa
See All by Sotaro Karasawa
大「個人開発サービス」時代に僕たちはどう生きるか
sotarok
22
11k
P2B Haus法人サポータープランのご提案
sotarok
2
1.5k
ソフトウェアxスタートアップから見た飲食と配送の世界 / The World of Food Deliverlies and Restaurant Businesses from a Software and Startup Perspective
sotarok
2
1.3k
CTO 3度目の正直 / My 3rd CTO Career
sotarok
21
10k
Introduction to the Corporate Solutions Engineering at MTC2018
sotarok
1
36k
Mercari meetup for Corporate Engineering #1 / What is "Corporate Engineering"?
sotarok
2
2.4k
Markdown and WYSIWYG
sotarok
1
6.2k
20 Jan 2017 / Moving Beyond Borders - Mercari DAY
sotarok
8
15k
PHPBLT の心得 / PHPBLT #5 @ペパボ
sotarok
5
3.6k
Other Decks in Technology
See All in Technology
OpenAI gpt-oss ファインチューニング入門
kmotohas
2
1.1k
自動テストのコストと向き合ってみた
qa
0
200
extension 現場で使えるXcodeショートカット一覧
ktombow
0
220
AWS IoT 超入門 2025
hattori
0
250
そのWAFのブロック、どう活かす? サービスを守るための実践的多層防御と思考法 / WAF blocks defense decision
kaminashi
0
110
職種別ミートアップで社内から盛り上げる アウトプット文化の醸成と関係強化/ #DevRelKaigi
nishiuma
2
160
10年の共創が示す、これからの開発者と企業の関係 ~ Crossroad
soracom
PRO
1
640
実装で解き明かす並行処理の歴史
zozotech
PRO
1
630
SwiftUIのGeometryReaderとScrollViewを基礎から応用まで学び直す:設計と活用事例
fumiyasac0921
0
150
小学4年生夏休みの自由研究「ぼくと Copilot エージェント」
taichinakamura
0
530
Trust as Infrastructure
bcantrill
1
370
英語は話せません!それでも海外チームと信頼関係を作るため、対話を重ねた2ヶ月間のまなび
niioka_97
0
130
Featured
See All Featured
Keith and Marios Guide to Fast Websites
keithpitt
411
23k
Agile that works and the tools we love
rasmusluckow
331
21k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
9
850
Docker and Python
trallard
46
3.6k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
37
2.6k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
114
20k
Six Lessons from altMBA
skipperchong
28
4k
Raft: Consensus for Rubyists
vanstee
139
7.1k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
45
2.5k
How To Stay Up To Date on Web Technology
chriscoyier
791
250k
Faster Mobile Websites
deanohume
310
31k
Transcript
ೖ PHP 5.4 Introduction of PHP 5.4 @sotarok http://git.io/sotarok PHPษڧձ@౦ژ
#58
PHP 5.4 ! ͏ͬͯ·͔͢
PHP 5.4 ࠓͷ
WEB+DB PRESS Vol.65 http://www.amazon.co.jp/dp/477414830X/
WEB+DB PRESS Vol.59 http://www.amazon.co.jp/dp/4774143898/ ͳΜͱ ·ͪΘͼͨʂ
ػೳͱ͔հ ͪΐͬͱͬͯΈΔ ֤ϥΠϒϥϦͷରԠঢ়گ PHP 5.4 Ҡߦ͍ͭ͠·͠ΐ͏͔ ࠓͷ
Crocos, Inc. Ethna git-daily ύʔϑΣΫτPHP ࣗݾհ Red Bull ϓϦϯ Perfume
͍ΖΫϩʔόʔZ Sotaro Karasawa ฑ૱ଠ ϩϦϙ͓͡͞Μ
PHP 5.4 ʹ͍ͭͯ
PHP 5.4 ৽ػೳʹ͍ͭͯ ·ͣಡΉ͖ࢿྉ PHP 5.4: The New Bits http://speakerdeck.com/u/dshafik/p/php-54-the-new-bits
Begin your love affair with traits http://slidesha.re/ssKtnP PHP 5.3.x ͔Β PHP 5.4.x ͷҠߦ http://www.php.net/manual/ja/migration54.php
PHP 5.4 - Build in server - Array short syntax
- Array Dereferencing - Traits - Binary Notation - Upload Progress - Delete Deprecation (safe mode, magic quotes etc.) - ͋ͱ͍Ζ͍Ζ (͒
Array Short Syntax $array = [1, 2, 'miyazaki' => 'aoi',];
Array Dereferencing $basename = pathinfo(__FILE__)['basename'];
Class member access on instantiation echo (new \DateTime())->format('Y-m-d');
SessionHandler http://www.php.net/manual/ja/class.sessionhandler.php http://www.php.net/manual/ja/class.sessionhandlerinterface.php class DumpSessionHandler extends SessionHandler { public function
read($id) { $data = parent::read($id); var_dump($data); return $data; } }
Traits http://jp.php.net/manual/ja/language.oop5.traits.php trait FileWriter { public function write($content) { //
... } } class FileLogger implements Logger { use FileWriter; }
ͪΐͬͱ͍ͬͯ͡ΈΔ
͍·͙͑͢Δ PHP 5.4 CentOS → Debian ʹೖΕସ͑Δ ·͊ɺremi-test Ͱ͑Δͣ Debian
→ dotdeb http://www.dotdeb.org/2012/03/13/packages-of-php-5-4-0-have-been- updated/ Crocos → http://php.marvel.strk.jp/deb/
ιʔε͔ΒೖΕΔ PHP 5.4 ࠷ۙྲྀߦΓͷ php-build + phpenv Built-in-server ͕͋Δ͓ӄͰԸܙഒ૿ ࢀߟจݙ:
phpenv Ͱෳͷ PHP ڥΛཧ͢Δ - Born Too Late http://blog.yuyat.jp/archives/1446 phpenv+php-build+pyrusͰͷෳόʔδϣϯPHPཧͳͲ http://blog.dataich.com/2012/01/11/multiple-versions-php-phpenv- phpbuild-pyrus/
໘͔ͩΒαʔό1आΓΔ ͘͞ΒVPS http://vps.sakura.ad.jp/ 3/29 ϦχϡʔΞϧ͔ͩΒগͭ͠ͱྑ͍͔ ϋΠεϖοΫʹʂ҆͘ʂ
࣮ࡍʹ͍ͬͯ͡ΈΔ ...
֤ϥΠϒϥϦͷରԠঢ়گʹ͍ͭͯ ͋·ΓࢀߟʹͳΒͳ͍ใ
Symfony2, Doctrine2 ͏͍ͯ͝·͢
APC × 3.1.9 ͏ͳΒ SVN ͷͭ $ svn co https://svn.php.net/repository/pecl/apc/
trunk ./apc-src $ cd apc-src $ phpize $ ./configure && make && sudo make install
Xdebug × 2.1.4 2.2.0 RC2 or GitHub $ git clone
https://github.com/derickr/xdebug.git $ cd xdebug $ phpize $ ./configure && make && sudo make install
Ethna ? 2.6.0 Ͱ PHP 5.3 ରԠͯ͠·͕͢φχΧ
ͦͷଞ ಈ͘ͱࢥ͍·͢ PHP 5.3 Ͱਅ໘ʹͬͯͨϠπͳΒಈ͘
PHP 5.4 Ҡߦ͍ͭ͠·͠ΐ͏͔
Ҡߦʹ͋ͨͬͯҙ͖͢͜ͱ ΄ͱΜͲͳ͍ʂ ʮPHP 5.3 ·ͰͷରԠΛ͔ͬ͠Γ͖͍ͬͯͯΕʯ(2ճ) ·ͩ Production ʹೖΕͯͳ͍͚ͲɺStaging Ͱฐ ࣾΞϓϦ
(PHP 5.3 + Symfony2) ݩؾʹಈ͍͍ͯΔ
Ҡߦʹ͋ͨͬͯҙ͖͢͜ͱ ֦ுػೳܥҙ͕ඞཁ͋Δఔɻ ݹ͍ίʔυΛ࣋ͬͯΔਓ: - magic quotes ܥؔ - register globals
- Call-time pass-by-reference ͍͜ͷΜͷͰυΩυΩ͢Δਓ PHP 5.4 Ҏલʹ 5.3 ʹ͋͛ΒΕͳ͍ͷͰઆ
Call-time pass-by-reference function add(&$a) { $a += 1; } $b
= 2; add(&$b); // => Fatal error: Call-time pass-by- reference has been removed
͋ͳ͕͍ͨͭ PHP 5.4 Λ͓͏ͱ͖͔͢
!?
None
ͳͥ PHP 5.4 Λࠓ͙͓͢͏ͱ͖͔͢ - ϓϩάϥϛϯάɾ࠶ར༻ͷଅਐ: Traits - ͍ɾলϝϞϦ -
http://travis-ci.org/#!/sotarok/git-daily/builds/800708h PHP 5.3: 13.00Mb, PHPUnit 4s, Behat 0.867s PHP 5.4: 7.75Mb, PHPUnit 3s, Behat 0.637s
ͳͥ PHP 5.4 Λࠓ͙͓͢͏ͱ͖͔͢ - ʮͦ͏͠ͳ͚ΕͳΒͳ͘ͳ͔ͬͯΒʯͰ͍ - ͕࣌ؒܦཱͯͭ΄ͲҠߦେม - όʔδϣϯ͕͕ؒΔ΄ͲҠߦେม
ྫ: ʮSymfony ͕PHP 5.3 ࠓ͔Βαϙʔτ͠ͳ͘ͳΔ Β͍͠ΑʂͲ͏͠Α͏Կ४උ͍ͯ͠ͳ͍ʂʯ
ͳͥ PHP 5.4 Λࠓ͙͓͢͏ͱ͖͔͢ - ٕज़ऀͷཆ - ૣ͔͘ΒΩϟονΞοϓ͢Δ͜ͱͰɺTraits ͳͲΛ ༻͍ͨϓϩάϥϛϯάͷͰ͖ΔਓɾڥΛͭ͘Δ
- ϓϥΫςΟεΛੵͤ͞Δ - Traits ΛͬͨϥΠϒϥϦ࣍ʑͱग़ͯ͘Δͣ - ݹ͍όʔδϣϯͰϝϯς͠ଓ͚Δίετ - ࠓେม͚ͩͲ ͞Βʹݴ͑
PHP 5.3 ͕͍ͭ·Ͱαϙʔτ͞ΕΔ͔ 3/3 ʹͦ͏͍͕͍ͬͨٞ͋ͬͯΔ ·͕ͩ݁ग़ΔΑ͏ͳஈ֊Ͱͳ͍ https://wiki.php.net/rfc/php53eol http://news.php.net/php.internals/58469
·ͱΊ
·ͱΊ PHP 5.4 Λ͍·͠ΐ͏