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
ソフトウェア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
20
9.7k
Introduction to the Corporate Solutions Engineering at MTC2018
sotarok
1
36k
Mercari meetup for Corporate Engineering #1 / What is "Corporate Engineering"?
sotarok
2
2.3k
Markdown and WYSIWYG
sotarok
1
5.9k
20 Jan 2017 / Moving Beyond Borders - Mercari DAY
sotarok
8
15k
PHPBLT の心得 / PHPBLT #5 @ペパボ
sotarok
5
3.4k
Wiki についての今昔物語 / Crowi
sotarok
5
14k
PHPでダイエット / Dietcube #phpblt
sotarok
2
4.3k
Other Decks in Technology
See All in Technology
Engineer Career Talk
lycorp_recruit_jp
0
160
Terraform CI/CD パイプラインにおける AWS CodeCommit の代替手段
hiyanger
1
240
Lambdaと地方とコミュニティ
miu_crescent
2
370
サイバーセキュリティと認知バイアス:対策の隙を埋める心理学的アプローチ
shumei_ito
0
380
Taming you application's environments
salaboy
0
180
OCI Network Firewall 概要
oracle4engineer
PRO
0
4.1k
DMARC 対応の話 - MIXI CTO オフィスアワー #04
bbqallstars
1
160
【若手エンジニア応援LT会】ソフトウェアを学んできた私がインフラエンジニアを目指した理由
kazushi_ohata
0
150
インフラとバックエンドとフロントエンドをくまなく調べて遅いアプリを早くした件
tubone24
1
430
Exadata Database Service on Dedicated Infrastructure(ExaDB-D) UI スクリーン・キャプチャ集
oracle4engineer
PRO
2
3.2k
OCI Security サービス 概要
oracle4engineer
PRO
0
6.5k
適材適所の技術選定 〜GraphQL・REST API・tRPC〜 / Optimal Technology Selection
kakehashi
1
170
Featured
See All Featured
For a Future-Friendly Web
brad_frost
175
9.4k
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
Raft: Consensus for Rubyists
vanstee
136
6.6k
10 Git Anti Patterns You Should be Aware of
lemiorhan
654
59k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
44
2.2k
Visualization
eitanlees
145
15k
Become a Pro
speakerdeck
PRO
25
5k
Docker and Python
trallard
40
3.1k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
The Cult of Friendly URLs
andyhume
78
6k
A Philosophy of Restraint
colly
203
16k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
120
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 Λ͍·͠ΐ͏