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.3k
ソフトウェア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.3k
Markdown and WYSIWYG
sotarok
1
6k
20 Jan 2017 / Moving Beyond Borders - Mercari DAY
sotarok
8
15k
PHPBLT の心得 / PHPBLT #5 @ペパボ
sotarok
5
3.5k
Wiki についての今昔物語 / Crowi
sotarok
5
15k
Other Decks in Technology
See All in Technology
DevinでAI AWSエンジニア製造計画 序章 〜CDKを添えて〜/devin-load-to-aws-engineer
tomoki10
0
220
事業を差別化する技術を生み出す技術
pyama86
2
540
サイト信頼性エンジニアリングとAmazon Web Services / SRE and AWS
ymotongpoo
7
1.9k
いまからでも遅くない!コンテナでWebアプリを動かしてみよう!コンテナハンズオン編
nomu
0
180
遷移の高速化 ヤフートップの試行錯誤
narirou
6
2k
データモデルYANGの処理系を再発明した話
tjmtrhs
0
330
DeepSeekとは?何がいいの? - Databricksと学ぶDeepSeek! 〜これからのLLMに備えよ!〜
taka_aki
1
180
LINE NEWSにおけるバックエンド開発
lycorptech_jp
PRO
0
390
AWSアカウントのセキュリティ自動化、どこまで進める? 最適な設計と実践ポイント
yuobayashi
7
1.8k
データエンジニアリング領域におけるDuckDBのユースケース
chanyou0311
9
2.6k
20250304_赤煉瓦倉庫_DeepSeek_Deep_Dive
hiouchiy
2
130
Log Analytics を使った実際の運用 - Sansan Data Hub での取り組み
sansantech
PRO
0
120
Featured
See All Featured
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
134
33k
Build The Right Thing And Hit Your Dates
maggiecrowley
34
2.5k
Raft: Consensus for Rubyists
vanstee
137
6.8k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
2.1k
BBQ
matthewcrist
87
9.5k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
33
2.8k
Visualization
eitanlees
146
15k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
129
19k
Bash Introduction
62gerente
611
210k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
233
17k
Why Our Code Smells
bkeepers
PRO
336
57k
What's in a price? How to price your products and services
michaelherold
244
12k
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 Λ͍·͠ΐ͏