note 125457 added to function.chdir
| From: | nesk at xakep dot ru | Date: | Sat, 24 Oct 2020 12:43:14 +0000 |
| Subject: | note 125457 added to function.chdir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-215635@lists.php.net to get a copy of this message | ||
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;
}
?>
----
Server IP: 45.112.84.4
Probable Submitter: 185.85.3.174 (proxied: 95.165.142.132)
----
Manual Page -- http://php.net/manual/en/function.chdir.php
Edit -- https://master.php.net/note/edit/125457
Del: integrated -- https://master.php.net/note/delete/125457/integrated
Del: useless -- https://master.php.net/note/delete/125457/useless
Del: bad code -- https://master.php.net/note/delete/125457/bad+code
Del: spam -- https://master.php.net/note/delete/125457/spam
Del: non-english -- https://master.php.net/note/delete/125457/non-english
Del: in docs -- https://master.php.net/note/delete/125457/in+docs
Del: other reasons-- https://master.php.net/note/delete/125457
Reject -- https://master.php.net/note/reject/125457
Search -- https://master.php.net/manage/user-notes.php