Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork405
Add extension from source
This guide is written for developers with basic knowledge of compiling packages, if you have any questions please feel free to askhere.
OnUbuntu andmacOS extensions can be compiled and installed from a git repository by suffixing the extension's name withrepository@version.
For example to compile and installmongodb from its GitHub repositorymongodb/mongo-php-driver and tag1.15.0:
-name:Setup PHP with mongodb from sourceuses:shivammathur/setup-php@v2with:php-version:'8.2'extensions:mongodb-mongodb/mongo-php-driver@1.15.0
The version can be a branch name or tag as supported bygit clone -b <name>. The clone is performed recursively, i.e. submodules if any, will be cloned as well.
The input format is<extension-name>-<repository>@<branch/tag>.
By default, the extension repository is cloned from GitHub. If the extension is hosted on any other git provider. You need to specify the complete repository URL.
For example to compile and installcsv extension from its repository hosted on GitLab:
-name:Setup PHP with csv from sourceuses:shivammathur/setup-php@v2with:php-version:'7.4'extensions:csv-https://gitlab.com/Girgias/csv-php-extension@0.3.1
If the extension is not in the root directory of the repository, you can specify the sub-directory using the environment variable<EXTENSION>_PATH. For example forprotobuf, the environment variable will bePROTOBUF_PATH.
-name:Setup PHP with protobuf from sourceuses:shivammathur/setup-php@v2with:php-version:'7.4'extensions:protobuf-protocolbuffers/protobuf@v3.15.2env:PROTOBUF_PATH:php/ext/google/protobuf
Extensions can require various configuration options. While compiling an extension the call to the configure script can look like this
PREFIX_OPTS ./configure SUFFIX_OPTS
ThePREFIX_OPTS can be Makefile variables likeCFLAGS,SUFFIX_OPTS can bem4 inputs like--enable-extension.
Sosetup-php supports the following environment variables.
<EXTENSION>_CONFIGURE_PREFIX_OPTS<EXTENSION>_CONFIGURE_SUFFIX_OPTSor<EXTENSION>_CONFIGURE_OPTS(alias)
For example to compilehttp extension from source:
-name:Setup PHP with http from sourceuses:shivammathur/setup-php@v2with:php-version:'8.0'extensions:raphf, http-m6w6/ext-http@v4.0.0env:HTTP_CONFIGURE_PREFIX_OPTS:"CFLAGS=-Wno-implicit-function-declaration"HTTP_CONFIGURE_OPTS:"--with-http"
Some extensions require external libraries. To setup libraries along with compiling the extension the following environment variables are supported.
<EXTENSION>_LIBS<EXTENSION>_LINUX_LIBS<EXTENSION>_DARWIN_LIBS.
If you are using a single operating system in a workflow, then you can use<EXTENSION>_LIBS. In a multi OS workflow, you can use<EXTENSION>_LINUX_LIBS for Ubuntu workflows and<EXTENSION>_DARWIN_LIBS for macOS workflows.
Libraries on Ubuntu are installed usingapt. On MacOS libraries are installed using Homebrew.
For example to compile and installredis extension withlz4 support in a cross-platform workflow:
-name:Get liblz4 directoryid:lz4run:| if [ "$(uname -s)" = "Linux" ]; then echo "lz4_dir=/usr" >> "$GITHUB_OUTPUT" else echo "lz4_dir=$(brew --prefix)/opt/lz4" >> "$GITHUB_OUTPUT" fi-name:Setup PHP with redis from source with lz4 supportuses:shivammathur/setup-php@v2with:php-version:'8.0'extensions:redis-phpredis/phpredis@5.3.7env:REDIS_CONFIGURE_OPTS:--enable-redis --enable-redis-lz4 --with-liblz4=${{ steps.lz4.outputs.lz4_dir }}REDIS_LINUX_LIBS:liblz4-devREDIS_DARWIN_LIBS:lz4