How do I add custom extensions when PHP is running?
Preparatory work
Dependent tool
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.
DockerFun
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.mdhttps://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