thecodingmachine / docker-images-php

A set of PHP Docker images
MIT License
768 stars 137 forks source link

feat: add support ffi extension #345

Closed qkdreyer closed 1 year ago

qkdreyer commented 1 year ago

Summary

This PR fixes/implements :

Checklist

mistraloz commented 1 year ago

Thanks for your PR. I lunched CI testing but please :

PS: except if i missed something, php-ffi in not available for php7.2 / 7.3. If it's true, manage an exception in test case (simple if on function define, you can copy/paste from another) and update README to tell with that ffi is available from 7.4 included.

qkdreyer commented 1 year ago

@mistraloz I've applied your suggestions ✅

mistraloz commented 1 year ago

Perfect, thx :)

qkdreyer commented 1 year ago

tests were failing (https://github.com/thecodingmachine/docker-images-php/actions/runs/3581372011/jobs/6025554623#step:8:22) because module is named FFI not ffi, I've just fixed that, but I'm not sure if we should enable it with PHP_EXTENSIONS=ffi or PHP_EXTENSIONS=FFI, wdyt?

qkdreyer commented 1 year ago

ping @mistraloz

mistraloz commented 1 year ago

I'm not sure if we should enable it with PHP_EXTENSIONS=ffi or PHP_EXTENSIONS=FFI, wdyt?

PHP_EXTENSIONS is not case sensitive :

/**
 * Returns a list of extensions available in the PHP_EXTENSIONS environment variable
 *
 * @return array<int, string>
 */
function getPhpExtensionsEnvVar(): array
{
    static $phpExtensions = null;
    if ($phpExtensions !== null) {
        return $phpExtensions;
    }
    $delimiter = [',', '|', ';', ':'];
    $replace = str_replace($delimiter, ' ', getenv('PHP_EXTENSIONS'));
    $phpExtensions = explode(' ', $replace);
    $phpExtensions = array_map('trim', $phpExtensions);
    $phpExtensions = array_map('strtolower', $phpExtensions);
    $phpExtensions = array_filter($phpExtensions);
    return $phpExtensions;
}