Contenu connexe
Similaire à PHPの今とこれから2015 (20)
Plus de Rui Hirokawa (15)
PHPの今とこれから2015
- 4. PHP アンケート 2015
主に使っているPHPのバージョン
1) PHP <=5.3
2) PHP 5.4
3) PHP 5.5
4) PHP 5.6
5) PHP 7.0
6) 使ってない
4
- 7. PHPリリースサイクル
7
2012 2013 2014 2015 2016 2017 2018
5.3
5.4
5.5
5.6
アクティブサポート
セキュリティ修正のみ
2015/10
リリースサイクル:1年
ライフサイクル:3年(バグ修正:2年、セキュリティ修正のみ:1年)
EOL 2015/9/14
EOL 2016/7/10
EOL 2017/8/28
https://wiki.php.net/rfc/releaseprocess
http://php.net/supported-versions.php
- 8. PHPリリース情報
Release 5.4 5.5 5.6 変更
2014/10/16 5.4.34 5.5.18 5.6.2 CVE-2014-3670, 3668 ,3669
2014/11/13 5.4.35 5.5.19 5.6.3 CVE-2014-3710
2014/12/18 5.4.36 5.5.20 5.6.4 CVE-2014-8142
2015/1/22 5.4.37 5.5.21 5.6.5 CVE-2015-0231,0232, CVE-2014-9427,9652
2015/2/19 5.4.38 5.5.22 5.6.6 CVE-2015-0235,0273,2301, CVE-2014-9705
2015/3/19 5.4.39 5.5.23 5.6.7 CVE-2015-2787,2348,2305,4147,4148,2331
2015/4/16 5.4.40 5.5.24 5.6.8 CVE-2015-3330
2015/5/14 5.4.41 5.5.25 5.6.9 CVE-2015-4025,4026,2325,2326,4021
2015/6/11 5.4.42 5.5.26 5.6.10 CVE-2015-3414,3415,3416,4642,4644
2015/7/9 5.4.43 5.5.27 5.6.11 CVE-2015-3152,5589,5590
2015/8/6 5.4.44 5.5.28 5.6.12 CVE-2015-6831,6832,6833
2015/9/3 5.4.45 5.5.29 5.6.13 CVE-2015-6834,6835,6836,6837,6838
2015/10/1 5.5.30 5.6.14
8
escapeshellarg()
OSコマンドインジェクション
- 9. PHP 7.0 改善/変更のポイント
大幅高速化
致命的エラーを例外捕捉可能に
古いSAPI、エクステンションの削除
ヌル合体演算子 (??)
結合比較演算子 ( <=> )
戻り値型宣言
スカラー型宣言
匿名クラス
9
- 10. より速く、快適に
Athlon II X4 640 3.0GHz, Ubuntu 14.04 10
0
0.5
1
1.5
2
2.5
3
3.5
4
PHP 5.4 PHP 5.5 PHP 5.6 PHP 7.0 HHVM 3.9
実行時間[s]
Zend/bench.php strcat(200000)
sieve(30)
nestedloop(12)
matrix(20)
heapsort(20000)
hash2(500)
hash1(50000)
fibo(30)
ary3(2000)
ary2(50000)
ary(50000)
ackermann(7)
mandel2
mandel
simpleudcall
simpleucall
simplecall
simple
PHP 7はPHP 5.6よりも大幅高速化
変数コンテナ等、内部構造を大幅最適化し、メモリを削減
- 11. より速く、快適に
Athlon II X4 640 3.0GHz, Ubuntu 14.04 11
0
2
4
6
8
10
12
14
16
PHP 5.4 PHP 5.5 PHP 5.6 PHP 7.0 HHVM 3.9
実行時間[s]
Zend/micro_bench.php $x = $f ? $f : tmp
$x = $f ? $f : $a
$x = $f ?: tmp
$x = $a ?: null
$x = $str[0]
$x = $hash['v']
$x = $GLOBALS['v']
$x = $_GET
$x = TEST
new Foo()
$x = Foo::TEST
$this->f()
empty($this->x)
isset($this->x)
$this->x--
$this->x++
--$this->x
++$this->x
$this->x += 2
$this->x = 0
$x = $this->x
Foo::f()
self::f()
empty(Foo::$x)
isset(Foo::$x)
Foo::$x = 0
$x = Foo::$x
empty(self::$x)
isset(self::$x)
self::$x = 0
$x = self::$x
int_func()
undef_func()
func()
empty_loop
- 12. WordPress 4.4 ベンチマーク
Athlon II X4 640 3.0GHz, Ubuntu 14.04 12
0
0.5
1
1.5
2
2.5
PHP 5.6 PHP 7.0 HHVM 3.9
PHP 7はPHP 5.6よりも約2倍高速
HHVM 3.9は更に約10%高速
リクエスト/秒の比(PHP 5.6: 1)
- 13. スカラー型宣言と戻り型宣言
スカラー型宣言と戻り型宣言のサポート
デフォルト動作は従来と同じ(non strictモード)
Strictモードにすると型チェックが有効になる
13
RFC: https://wiki.php.net/rfc/scalar_type_hints_v5
<?php
function add($a, $b) {
return $a+$b;
}
echo add(“2“,”3”); // 5
<?php
function add(int $a, int $b) : int {
return $a+$b;
}
echo add(“2“,”3”);
PHP 5.6 PHP 7
declare(strict_types = 1);
// エラー
- 15. PHP7: ’<=>’ 演算子
結合比較演算子:スペースシップ演算子
function order_func($a, $b) {
return ($a < $b) ? -1 : (($a > $b) ? 1 : 0);
}
15
function order_func($a, $b) {
return $a <=> $b;
}
https://wiki.php.net/rfc/combined-comparison-operator
PHP 5.6
PHP 7
- 16. PHP7: パーサ関連の変更
Abstract Syntax Tree (AST) :パーサとコンパイラを分離
コード管理が容易→ 最適化、メモリ削減
変数構文の統一
16
$obj->$bar [‘foo’]
RFC: https://wiki.php.net/rfc/abstract_syntax_tree
$obj->{$bar [‘foo’]}
{$obj->$bar} [‘foo’]
PHP 5.6
PHP 7
RFC: https://wiki.php.net/rfc/uniform_variable_syntax
- 17. PHP 7:互換性に関する変更
エクステンション削除: ereg, mysql, mssql
SAPI削除: 22種類→7種類
apache2handler, cgi, cli, embed, fpm, litespeed, phpdbg
ASP(<% .. %>)、Script(<script launguage=“php”></script>)廃止
newオブジェクトの参照代入廃止
PHP4形式のコンストラクタ: E_DEPRECATED
エクステンションは要変更:
http://gophp7.org/gophp7-ext/
17
class C {}
$c =& new C;
class C {
function C() {}
}
$c = new C();
- 25. HHVM
Facebookが開発/公開するPHP/Hack実行環境
2010/2 HipHop for PHP:C++トランスレータ、互換性、管理
2011/12 HipHop Virtual Machine(HHVM):JITベースVM
リソース低減化(>66%)と速度改善(>5x), WP (2.5x)
FastCGI+Webサーバで実行
PHPスクリプト
バイトコード
パース/コンパイル
Zend VM
実行
PHP/Hackスクリプト
HipHopバイトコード(HHBC)
パース/コンパイル(AST)
JITコンパイラ(最適化)
ネーティブコード
HHVM
実行(x86-64,ARM64)
25
hhvm.com
- 26. Hack
PHPを拡張したHHVM用の言語: 2014/2公開
目的:大規模開発における開発効率化
関数、クラスの型アノテーション:型チェッカ
PHPからの移行は容易:移行ツール、gradual typing
HHVMにおける最適化にも寄与
型拡張:generics,collections,nullable
非同期プログラミング:async,await
26
hacklang.org