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.4k
入門 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
1
1.1k
CTO 3度目の正直 / My 3rd CTO Career
sotarok
19
9.4k
Introduction to the Corporate Solutions Engineering at MTC2018
sotarok
1
35k
Mercari meetup for Corporate Engineering #1 / What is "Corporate Engineering"?
sotarok
2
2.3k
Markdown and WYSIWYG
sotarok
1
5.7k
20 Jan 2017 / Moving Beyond Borders - Mercari DAY
sotarok
8
15k
PHPBLT の心得 / PHPBLT #5 @ペパボ
sotarok
5
3.3k
Wiki についての今昔物語 / Crowi
sotarok
5
14k
PHPでダイエット / Dietcube #phpblt
sotarok
2
4.2k
Other Decks in Technology
See All in Technology
Google Cloud Next '24 Recap in ZOZO AIにより変わる開発 運用/Development and operation changed by AI
gachimuchiengineer
0
190
DevRelによる信頼構築とデータ駆動で変わるエンジニア採用 / DevRel Trust Building to Data Driven Engineering Hiring
bobtani
1
120
【TSkaigi】2024/05/11 当日スライド
kimitashoichi
14
3.9k
Documentação de Produtos: Artefatos essenciais na prática
rigolon
1
290
Deno で作る快適な “as Code” プラットフォーム – TSKaigi 2024
pizzacat83
4
300
拓展QA日常工作的邊界
line_developers_tw
PRO
0
490
シンプルなHITL機械学習と様々なタスクにおけるHITL機械学習
naohachi89
0
310
データ基盤を支える技術
chanyou0311
5
2.9k
TypescriptでのContextualな構造化ロギングと社内全体への導入
leveragestech
3
550
データ分析力を高めるSQL研修サービス『SQL Everyone』
hikarut
1
370
試作とデモンストレーション / Prototyping and Demonstrations
ks91
PRO
0
160
複雑なビジネスルールに挑む:正確性と効率性を両立するfp-tsのチーム活用術 / Strike a balance between correctness and efficiency with fp-ts
kakehashi
5
3.4k
Featured
See All Featured
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
14
1.5k
[RailsConf 2023] Rails as a piece of cake
palkan
28
4k
Six Lessons from altMBA
skipperchong
22
3k
YesSQL, Process and Tooling at Scale
rocio
165
13k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
155
14k
Building Effective Engineering Teams - LeadDev
addyosmani
33
1.9k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
21
2k
The World Runs on Bad Software
bkeepers
PRO
61
6.7k
10 Git Anti Patterns You Should be Aware of
lemiorhan
649
58k
RailsConf 2023
tenderlove
9
580
The Illustrated Children's Guide to Kubernetes
chrisshort
32
47k
No one is an island. Learnings from fostering a developers community.
thoeni
16
2.1k
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 Λ͍·͠ΐ͏