introduce php7
TRANSCRIPT
안정수@findstar
내가 아는 Laravel Framework를 소개합니다. PHP7 으로 뛰어들기
안정수
Xpressengine 개발PHP, Java, Objective-c, react.js
@findstar
발표자 소개
1. PHP7 is coming
2. Performance
3. New features
4. PHP 버전 이야기
5. Migration
목차
1. PHP7 is Coming
PHP 7 Is ComingAre your Web Application Ready?
1-1. PHP7?
2015. 10월 PHP7이 나옵니다!
(현재 RC1)
PHP5.4
PHP5.5
PHP5.6
PHP6
PHP7
1-2. PHP6는 어디로 갔나요?
PHP6 는 없어요....
1-2. PHP6 망!
Unicode 지원등등..... 진행하다가 GG
1-3. PHP-NG(next generation)
PHP-NG : 원래 별도의 브랜치
=> 7.0 됨
주된 내용은 : PHP 리팩토링!
1-4. PHP7 internal?
Zend engine 3.0
Smaller data structures
Fewer allocations
Less indirection
1-5. ZVAL
PHP5 PHP7
ZVAL 32 bytes 16 bytes
HashTable 72 bytes 56 bytes
object 96 bytes 40 bytes
1-6. Memory management
Less heap, more stack
Redevelop a new heap and optimize
Cpu cache friendly
2. Performance
3-1. Benchmark Test
XE1 - Board ab -k -c 50 -n 10000 http://xe1.app/
3-2. Benchmark Env
2012 mid Macbook Pro RetinaVagrant Rasmus Image
3-3. Benchmark Result
0
30
60
90
120
PHP 5.4 PHP 5.5 PHP 5.6 PHP 7.0
-1.66% 2.21% 40.11%
Request / Sec
80.6 79.2 80.9
113.34
XE - 게시판 목록 benchmark
3-5. 공식 Benchmark 4.4 ~ 7.0
짧은게 좋은겁니다..
0.8 PHP 7.0
참고 링크
3-6. WP - XE
0
30
60
90
120
PHP 5.6 PHP 7.0
WP 4.2.4
XE WP 4.2.4
XE
40.11%
102.4%
Requests / Sec
3-7. Local Composer
composer create-project laravel/laravel
php 5.6 : Memory usage: 160.27MB (peak: 222.83MB)
php 7.0 : Memory usage: 121.91MB (peak: 170.53MB)
23.42% 감소
3-8. Wordpress
워드 프레스 사이트가 php7 으로 구동환경을 바꾸었더니
CPU 자원 사용율이 72% 감소함
3-9. 결론
PHP7 = php5.6
PHP7 = php5.0
X 2
X 14
Speeeeeeeeeeeeed UP!
참고 링크
3. New features in PHP7
“PHP7”
3-1. Scalar type
function add(int $a, int $b) { return $a + $b }
echo add(1, 2); // 3
echo add(1.2, 2); // 3
3-1. Scalar type
declare(strict_types=1);
function add(int $a, int $b) { return $a + $b }
echo add(1, 2); // 3
echo add(1.2, 2); // TypeException
3-2. Return type
function add(int $a, int $b) : int { return $a + $b }
echo add(1, 2);
3-3. Spaceship operator
echo 2 <=> 2; // 0
echo 2 <=> 3; // -1
echo 2 <=> 1; // 0
3-3. Spaceship operator
function compareValue($a, $b){ return ($a < $b ) ? -1 : ( ($a > $b ) ? 1 : 0 );}
function compareValue2($a, $b){ return $a <=> $b;}
3-4. Engine Exceptions
BaseException abstract EngineException ParseException Exception ErrorException RuntimeException
fatals 대신 Exception
3-4. Engine Exceptions
class A { public function t(){ return 't called'; }}
$testa = new A();
echo $testa->aaa();
3-5. Group namespace
use BarLib\Bar\Foo\{ ClassA, ClassB, ClassC, ClassD as FooFoo };
3-6. Null Coalesce Operator
$username = isset($a)? $a : ‘foo’;
$username = $a?? ‘foo’;
3-7. Closure::call
class Foo{ public $bar;}$foo = new Foo;$foo->bar = 10;
$clo = function($a) { print_r($this->bar + $a );};
$clo->call($foo, 10);
3-8. Anonymous class
var_dump(new class(){});
object(class@anonymous)#1 (0) {}
3-9. Non static method call
class A{ function foo() { var_dump($this); }}class B{ function bar(){ A::foo(); }}
$b = new B;$b->bar();
4. Version of PHP
4-1 PHP 버전 지원
5.3 5.4
4-2 PHP 5.3 …..
4-3 지금 PHP 5.3, 5.4 쓰시나요?
4-4 하늘이 무너져도..
4-4 배포판의 보안 지원
CentOS 5.x php 5.3 2017 년 3월
CentOS 6.x php 5.3 2020년 11월
CentOS 7.x php 5.4 2024년 6월
Ubuntu 10.04 LTS php 5.3 , 지원중단.
Ubuntu 12.04 LTS php 5.3 2017년 4월
Ubuntu 14.04 LTS php 5.5.9
4-5 요약
5.3 과 5.4 를 사용중이시라면
버전을 올리시는게 좋습니다.
5. Migration
MISSION MIGRATION
5-1. Migration
in PHP 7 Doctrines..
- Do not fall into a “Python2 VS Python3” war
버전이 올라가도 하위 호한성을 유지합니다.
5-2. Removed
eregmssqlmysql
sybase_ct
aolserver, apache, apache_hooks, apache2filter,
caudium, continuityisapi, milter, nsapi, phttpd, pi3web, roxen, thttpd, tux, webjames
Extensions SAPI
5-3. Removed
<% %><%=
<script language=php></script>
<? 와 <?= 는 없어지지 않습니다.
5-3. Removed
call_user_method()
call_user_method_array()
call_user_func()
call_user_func_array()
5-4. Deprecated
5-5. Migration
http://php.net/manual/en/migration70.php
끝
새로운 모습의 PHP7을 기대해 봅니다
참고[php7]
http://php.net/manual/en/migration70.php
http://devzone.zend.com/4693/php-7-glance/
[slideshare]
http://www.slideshare.net/zymsys/new-in-php-7?related=2
http://www.slideshare.net/jpauli/php7-is-coming?next_slideshow=1
[php internal]
https://nikic.github.io/2015/05/05/Internal-value-representation-in-PHP-7-part-1.html
https://nikic.github.io/2015/06/19/Internal-value-representation-in-PHP-7-part-2.html
http://nikic.github.io/2014/12/22/PHPs-new-hashtable-implementation.html
[migration assistant report]
https://github.com/Alexia/php7mar