Slide 1

Slide 1 text

5 Smashing Changes Your Extension Will Encounter at PHP7 PHP BLT #1 / @Misumi_Rize

Slide 2

Slide 2 text

var_dump($me); → Twitter @Misumi_Rize → GitHub @MisumiRize

Slide 3

Slide 3 text

Today I talk about...

Slide 4

Slide 4 text

phpize ./configure make make install

Slide 5

Slide 5 text

Upgrading extensions for PHP7

Slide 6

Slide 6 text

gophp7-ext Extensions Catalog https://github.com/gophp7/gophp7-ext/wiki/ extensions-catalog

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

How can I upgrade my extension?

Slide 10

Slide 10 text

Upgrading PHP extensions from PHP5 to NG https://wiki.php.net/phpng-upgrading

Slide 11

Slide 11 text

First of all: 75% of code will change

Slide 12

Slide 12 text

Create another branch

Slide 13

Slide 13 text

php-memcached "php7" branch https://github.com/php-memcached-dev/php- memcached/tree/php7

Slide 14

Slide 14 text

Note When installing extesions from GitHub, pickle is suitable https://github.com/FriendsOfPHP/pickle ./bin/pickle install https://github.com/php-memcached-dev/php-memcached.git#php7

Slide 15

Slide 15 text

5 Smashing Changes

Slide 16

Slide 16 text

1. zval

Slide 17

Slide 17 text

zval → zval** Z_*_PP() is obsolete → Change to use zval* → PHP7 frequently uses zval directly → ALLOC_ZVAL, ALLOC_INIT_ZVAL, MAKE_STD_ZVAL has removed

Slide 18

Slide 18 text

2. char* at PHP

Slide 19

Slide 19 text

zend_string → Replacement of char* and int length → Many of PHP's API using char* has replaced to zend_string

Slide 20

Slide 20 text

3. smart_str

Slide 21

Slide 21 text

smart_string → smart_str is only renamed to smart_string → Struct's member is also renamed

Slide 22

Slide 22 text

4. HashTable

Slide 23

Slide 23 text

HashTable → Most API returns values, not SUCCESS, FAILURE → char*, length based API (similar to PHP5) remains → But length is changed to exclude trailing zero

Slide 24

Slide 24 text

5. Objects

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

Conclusion → There's no best practice to upgrade extension now → Reading core extensions will help

Slide 27

Slide 27 text

Addition: interesting thing I've found #if (PHP_MAJOR_VERSION >= 6)