Under what circumstances does php need to be extended with c? I am very grateful for providing guidance on the specific application scenarios!

Source: Internet
Author: User
Under what circumstances does php need to be extended with c? I am very grateful for providing guidance on the specific application scenarios! Under what circumstances does php need to be extended with c? I am very grateful for providing guidance on the specific application scenarios!

Reply content:

Under what circumstances does php need to be extended with c? I am very grateful for providing guidance on the specific application scenarios!

  • Performance Optimization in case of performance bottlenecks, such as intensive computing and massive string processing
  • Cross-process communication and data sharing, such as global data tables, configuration files, and database connection pools
  • Some functions in the local C library or executable files need to be used in php. These functions are not implemented in PHP, such as image processing tools such as imagemagick.

Let me talk about it based on the actual situation. I made two extensions. One was to call an ID Generation Program of the company, and the program was written in C (some mature internal algorithms, it is troublesome to write it again using PHP); the other is to use V8JS, but it cannot fully meet our needs, so we changed the source code (in fact, this is not a self-extension, or from PECL ).

I don't think any performance, process communication, or shared data must be extended. 1. How much performance do you need PHP to improve? The advantages of PHP are convenient in WEB development and mature components and frameworks, rather than performance 2. process Communication includes pcntl and posix, and signals and pipelines are all under discussion (but to be honest, it is not as good as perl multi-process communication) 3. it is more suitable to find a NoSQL database for shared data. If real-time processing is required, there are also a lot of applications such as message queues.

Therefore, I think the real need for expansion is mainly caused by the environment. If a program runs on its own, it will not have the PHP version. What do you do. Of course, some core components may also be written in C due to performance considerations, but there seem to be very few projects with such requirements. At least I have worked through it. If High-Performance Distributed Computing is required, interacting with data through custom interfaces, message queues, scheduled tasks, or batch processing of task queues does not mix with the web system at all.

The encryption/Decryption function writes the extension code in c.

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.