Due to the upgrade of the php7 kernel, do I have to develop two php extensions: php5 and php7?

Source: Internet
Author: User
I have checked several extensions of laruence, all of which are new branches to write php7 extensions; while swoole extensions use a php7-swapper.h for packaging, however, the php kernel used in it is relatively easy to use macros for operations. For example, the php5 extension is defined as below: {generation... I have checked several extensions of laruence, all of which are new branches to write extensions of PHP 7;
The swoole extension, but uses a php7-swapper.h to wrap, but it uses the php kernel inside something relatively easy to use macro to operate.

For example, the php5 extension is defined as follows:

Typedef struct _ test_obj {zend_object std; // put it in the header my_test_struct * my; int count;} test_obj;

According to the PHP 7 extension improvement suggestions, the struct needs to be modified:

Typedef struct _ test_obj {my_test_struct * my; int count; zend_object std; // put it at the end} test_obj;

And so on.MacroIt will make the code look ugly, but if it is not like this, it will take a lot of trouble to modify two pieces of code each time if it is divided into two branches for development.

I don't know if you have any good ideas. please enlighten me. thank you!

Reply content:

I have checked several extensions of laruence. they all pull new branches to write extensions of PHP 7;
The swoole extension, but uses a php7-swapper.h to wrap, but it uses the php kernel inside something relatively easy to use macro to operate.

For example, the php5 extension is defined as follows:

Typedef struct _ test_obj {zend_object std; // put it in the header my_test_struct * my; int count;} test_obj;

According to the PHP 7 extension improvement suggestions, the struct needs to be modified:

Typedef struct _ test_obj {my_test_struct * my; int count; zend_object std; // put it at the end} test_obj;

And so on.MacroIt will make the code look ugly, but if it is not like this, it will take a lot of trouble to modify two pieces of code each time if it is divided into two branches for development.

I don't know if you have any good ideas. please enlighten me. thank you!

The best way for user experience is to use a macro, so that users do not have to select a version. Of course, the disadvantage of this writing is that the two pieces of code will be mixed. after all, PHP7 has made great changes to the infrastructure. although most of the macros in PHP7 still follow the old version, they apply for variables on the stack, some of the variables related to the reference mechanism and other commonly used macros have changed. Therefore, the challenge of merging and writing a piece of data is quite large. If you are in trouble, just write separately like laruence. At present, most extensions are also written in separate modes first, and then merged together when they are more mature.

@ Thank you very much. now, please write separately. Wait Until PHP 7 is completely stable.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.