Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to add custom extensions for the PHP runtime

2025-04-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how to add custom extensions to the PHP runtime. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

The PHP language provides an extension mechanism (Extension) through which PHP extensions can enhance syntax, call library functions implemented by Cpicket +, and optimize execution performance. PHP extensions are platform-related dynamic link libraries, .so files on Linux and Mac platforms, and .dll files on Windows platforms. Because the development of function computing is usually on the Mac and Windows platforms, and the runtime is in Linux (Debain) environment, adding extensions to the PHP runtime of function computation will encounter the problem that either the local or the remote end cannot be debugged or run because of the dynamic link library platform. This article introduces the installation, local debugging, build and release of PHP extensions with the help of the simulation environment provided by Funcraft tools.

Preparation depends on tools

This project is developed under MacOS, the tools involved are platform-independent, and should also be applicable to Linux and Windows desktop systems. Before starting this example, make sure that the following tools are installed correctly, updated to the latest version, and configured correctly.

Docker

Fun

The Fun and Fcli tools rely on docker to simulate the local environment.

For MacOS users, you can use homebrew to install:

Brew cask install dockerbrew tap vangie/formulabrew install funbrew install fcli

For Windows and Linux user installation, please refer to:

Https://github.com/aliyun/fun/blob/master/docs/usage/installation.md

Https://github.com/aliyun/fcli/releases

After installation, remember to initialize the configuration by executing fun config first.

Note that if you have already installed fun, make sure that the fun version is above 3.6.1.

$fun-- version3.6.1PHP custom extension

Create a directory called extension in the function code directory and place the .ini and .so files corresponding to the extension in the extension directory. For example, the following is a custom extension of hello, assuming that there is a hello_world function in the extension:

. | _ extension | | _ hello.ini | | _ hello.so | _ main.php

Hello.ini

Extension=/code/extension/hello.so

Main.php

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 218

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report