When working with FFI under a PHP ZTS environment, there is no standard way to change the directory with libraries (dll/so/dylib/etc), so to get around this problem, you should use something like this polyfill:
<?php
$directory = 'path/to/libraries';
switch (\PHP_OS_FAMILY) {
    case 'Windows':
        \FFI::cdef('extern unsigned char SetDllDirectoryA(const char* lpPathName);', 'kernel32.dll')
            ->SetDllDirectoryA($directory)
        ;
        break;
    case 'Linux':
    case 'BSD':
        \FFI::cdef('int setenv(const char *name, const char *value, int overwrite);')
            ->setenv('LD_LIBRARY_PATH', $directory, 1)
        ;
        break;
    case 'Darwin':
        \FFI::cdef('int setenv(const char *name, const char *value, int overwrite);')
            ->setenv('DYLD_LIBRARY_PATH', $directory, 1)
        ;
        break;
}
?>