ffi / location
Finds the shared library file the dynamic linker loads for a name passed to FFI::cdef(), on Linux, macOS and Windows
1.2.0
2026-11-26 15:29 UTC
Requires
- php: ^8.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.95
- phpstan/phpstan: ^2.3
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-strict-rules: ^2.0
- phpunit/phpunit: ^10.5|^11.0|^12.0|^13.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
FFI::cdef() fails with a cryptic error when a shared library is missing, and the
same library is named differently on each operating system (libvulkan.so.1,
vulkan-1.dll, libvulkan.1.dylib). This package finds the library before you
load it, the way the dynamic linker of the operating system searches it, so you
can check that it is installed, pick the name that exists and report a clear error.
Installation
composer require ffi/location
Requires PHP 8.1 or later.
Usage
use FFI\Location\Locator; $pathname = Locator::resolve('libvulkan.so.1', 'vulkan-1.dll', 'libvulkan.1.dylib') ?? throw new RuntimeException('Vulkan is not installed'); $vulkan = FFI::cdef($header, $pathname);
Documentation
The search order on each system, the options and the limitations are described in the documentation.