Search by

ffi / location

Serafim

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

This package is auto-updated.

Last update: 2026-11-26 18:52:15 UTC


README

PHP 8.1+ Latest Stable Version Latest Unstable Version Total Downloads License MIT

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.