diff --git a/README.md b/README.md index e435a8e..2eded56 100644 --- a/README.md +++ b/README.md @@ -36,9 +36,14 @@ Or macOS: brew install vips ``` -You'll need to [enable FFI in your -PHP](https://www.php.net/manual/en/ffi.configuration.php), then add vips -to your `composer.json`: +php-vips does not yet support FFI preloading, so you need to enable FFI globally by setting `ffi.enable` to `true`. This has some security implications, since anyone who can run php on your server can use it to call any native library they have access to. + +Of course if attackers are running their own PHP code on your webserver you +are probably already toast, unfortunately. + +For more information see the [FFI Runtime Configuration](https://www.php.net/manual/en/ffi.configuration.php). + +Then add vips to your `composer.json`: ``` "require": { @@ -46,13 +51,6 @@ to your `composer.json`: } ``` -php-vips does not yet support preloading, so you need to enable FFI globally. -This has some security implications, since anyone who can run php on your -server can use it to call any native library they have access to. - -Of course if attackers are running their own PHP code on your webserver you -are probably already toast, unfortunately. - Finally, on php 8.3 and later you need to disable stack overflow tests. php-vips executes FFI callbacks off the main thread and this confuses those checks, at least in php 8.3.0. diff --git a/src/FFI.php b/src/FFI.php index 722065d..0636708 100644 --- a/src/FFI.php +++ b/src/FFI.php @@ -315,6 +315,9 @@ private static function init(): void } $msg .= ". Make sure that you've installed libvips and that '$vips_libname'"; $msg .= " is on your system's library search path."; + if ('preload' === ini_get('ffi.enable')) { + $msg .= "FFI is not enabled globally; this will prevent PHP from locating '$vips_libname'."; + } throw new Exception($msg); }