Introduce php7
-
Upload
jung-soo-ahn -
Category
Technology
-
view
1.883 -
download
0
Transcript of Introduce php7
![Page 1: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/1.jpg)
안정수@findstar
내가 아는 Laravel Framework를 소개합니다. PHP7 으로 뛰어들기
![Page 2: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/2.jpg)
안정수
Xpressengine 개발PHP, Java, Objective-c, react.js
@findstar
발표자 소개
![Page 3: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/3.jpg)
1. PHP7 is coming
2. Performance
3. New features
4. PHP 버전 이야기
5. Migration
목차
![Page 4: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/4.jpg)
1. PHP7 is Coming
PHP 7 Is ComingAre your Web Application Ready?
![Page 5: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/5.jpg)
1-1. PHP7?
2015. 10월 PHP7이 나옵니다!
(현재 RC1)
![Page 6: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/6.jpg)
PHP5.4
PHP5.5
PHP5.6
PHP6
PHP7
1-2. PHP6는 어디로 갔나요?
PHP6 는 없어요....
![Page 7: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/7.jpg)
1-2. PHP6 망!
Unicode 지원등등..... 진행하다가 GG
![Page 8: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/8.jpg)
1-3. PHP-NG(next generation)
PHP-NG : 원래 별도의 브랜치
=> 7.0 됨
주된 내용은 : PHP 리팩토링!
![Page 9: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/9.jpg)
1-4. PHP7 internal?
Zend engine 3.0
Smaller data structures
Fewer allocations
Less indirection
![Page 10: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/10.jpg)
1-5. ZVAL
PHP5 PHP7
ZVAL 32 bytes 16 bytes
HashTable 72 bytes 56 bytes
object 96 bytes 40 bytes
![Page 11: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/11.jpg)
1-6. Memory management
Less heap, more stack
Redevelop a new heap and optimize
Cpu cache friendly
![Page 13: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/13.jpg)
2. Performance
![Page 14: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/14.jpg)
3-1. Benchmark Test
XE1 - Board ab -k -c 50 -n 10000 http://xe1.app/
![Page 15: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/15.jpg)
3-2. Benchmark Env
2012 mid Macbook Pro RetinaVagrant Rasmus Image
![Page 16: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/16.jpg)
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
![Page 17: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/17.jpg)
3-5. 공식 Benchmark 4.4 ~ 7.0
짧은게 좋은겁니다..
0.8 PHP 7.0
참고 링크
![Page 18: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/18.jpg)
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
![Page 19: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/19.jpg)
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% 감소
![Page 20: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/20.jpg)
3-8. Wordpress
워드 프레스 사이트가 php7 으로 구동환경을 바꾸었더니
CPU 자원 사용율이 72% 감소함
![Page 21: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/21.jpg)
3-9. 결론
PHP7 = php5.6
PHP7 = php5.0
X 2
X 14
Speeeeeeeeeeeeed UP!
참고 링크
![Page 22: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/22.jpg)
3. New features in PHP7
“PHP7”
![Page 23: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/23.jpg)
3-1. Scalar type
function add(int $a, int $b) { return $a + $b }
echo add(1, 2); // 3
echo add(1.2, 2); // 3
![Page 24: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/24.jpg)
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
![Page 25: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/25.jpg)
3-2. Return type
function add(int $a, int $b) : int { return $a + $b }
echo add(1, 2);
![Page 26: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/26.jpg)
3-3. Spaceship operator
echo 2 <=> 2; // 0
echo 2 <=> 3; // -1
echo 2 <=> 1; // 0
![Page 27: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/27.jpg)
3-3. Spaceship operator
function compareValue($a, $b){ return ($a < $b ) ? -1 : ( ($a > $b ) ? 1 : 0 );}
function compareValue2($a, $b){ return $a <=> $b;}
![Page 28: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/28.jpg)
3-4. Engine Exceptions
BaseException abstract EngineException ParseException Exception ErrorException RuntimeException
fatals 대신 Exception
![Page 29: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/29.jpg)
3-4. Engine Exceptions
class A { public function t(){ return 't called'; }}
$testa = new A();
echo $testa->aaa();
![Page 30: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/30.jpg)
3-5. Group namespace
use BarLib\Bar\Foo\{ ClassA, ClassB, ClassC, ClassD as FooFoo };
![Page 31: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/31.jpg)
3-6. Null Coalesce Operator
$username = isset($a)? $a : ‘foo’;
$username = $a?? ‘foo’;
![Page 32: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/32.jpg)
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);
![Page 33: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/33.jpg)
3-8. Anonymous class
var_dump(new class(){});
object(class@anonymous)#1 (0) {}
![Page 34: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/34.jpg)
3-9. Non static method call
class A{ function foo() { var_dump($this); }}class B{ function bar(){ A::foo(); }}
$b = new B;$b->bar();
![Page 35: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/35.jpg)
4. Version of PHP
![Page 36: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/36.jpg)
4-1 PHP 버전 지원
5.3 5.4
![Page 37: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/37.jpg)
4-2 PHP 5.3 …..
![Page 38: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/38.jpg)
4-3 지금 PHP 5.3, 5.4 쓰시나요?
![Page 39: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/39.jpg)
4-4 하늘이 무너져도..
![Page 40: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/40.jpg)
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
![Page 41: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/41.jpg)
4-5 요약
5.3 과 5.4 를 사용중이시라면
버전을 올리시는게 좋습니다.
![Page 42: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/42.jpg)
5. Migration
MISSION MIGRATION
![Page 43: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/43.jpg)
5-1. Migration
in PHP 7 Doctrines..
- Do not fall into a “Python2 VS Python3” war
버전이 올라가도 하위 호한성을 유지합니다.
![Page 44: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/44.jpg)
5-2. Removed
eregmssqlmysql
sybase_ct
aolserver, apache, apache_hooks, apache2filter,
caudium, continuityisapi, milter, nsapi, phttpd, pi3web, roxen, thttpd, tux, webjames
Extensions SAPI
![Page 45: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/45.jpg)
5-3. Removed
<% %><%=
<script language=php></script>
<? 와 <?= 는 없어지지 않습니다.
![Page 46: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/46.jpg)
5-3. Removed
call_user_method()
call_user_method_array()
call_user_func()
call_user_func_array()
![Page 47: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/47.jpg)
5-4. Deprecated
![Page 48: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/48.jpg)
5-5. Migration
http://php.net/manual/en/migration70.php
![Page 50: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/50.jpg)
끝
새로운 모습의 PHP7을 기대해 봅니다
![Page 51: Introduce php7](https://reader033.fdocuments.net/reader033/viewer/2022051101/587012621a28ab7f428b494b/html5/thumbnails/51.jpg)
참고[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