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
P2B Haus法人サポータープランのご提案
sotarok
2
1.4k
ソフトウェアxスタートアップから見た飲食と配送の世界 / The World of Food Deliverlies and Restaurant Businesses from a Software and Startup Perspective
sotarok
2
1.2k
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.1k
20 Jan 2017 / Moving Beyond Borders - Mercari DAY
sotarok
8
15k
PHPBLT の心得 / PHPBLT #5 @ペパボ
sotarok
5
3.6k
Wiki についての今昔物語 / Crowi
sotarok
5
15k
Other Decks in Technology
See All in Technology
2025新卒研修・Webアプリケーションセキュリティ #弁護士ドットコム
bengo4com
3
10k
Observability for LLM Application lifecycle
ivry_presentationmaterials
1
230
Goでマークダウンの独自記法を実装する
lag129
0
200
第4回 関東Kaggler会 [Training LLMs with Limited VRAM]
tascj
11
1.5k
Yahoo!広告ビジネス基盤におけるバックエンド開発
lycorptech_jp
PRO
0
190
GitHub Copilot coding agent を推したい / AIDD Nagoya #1
tnir
2
4k
MySQL HeatWave:サービス概要のご紹介
oracle4engineer
PRO
4
1.6k
夢の印税生活 / Life on Royalties
tmtms
0
270
マイクロモビリティシェアサービスを支える プラットフォームアーキテクチャ
grimoh
1
160
帳票Vibe Coding
terurou
0
130
S3のライフサイクル設計でハマったポイント
mkumada
0
100
Backboneとしてのtimm2025
yu4u
3
1.3k
Featured
See All Featured
Making Projects Easy
brettharned
117
6.3k
Faster Mobile Websites
deanohume
309
31k
Optimising Largest Contentful Paint
csswizardry
37
3.4k
Visualization
eitanlees
146
16k
jQuery: Nuts, Bolts and Bling
dougneiner
64
7.9k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
1.4k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
9
770
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
139
34k
It's Worth the Effort
3n
187
28k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
183
54k
A designer walks into a library…
pauljervisheath
207
24k
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 Λ͍·͠ΐ͏