@@ -226,7 +226,16 @@ public function openLazy($filename, $flags = null, array $options = [])
226226
227227 private function openProcessIo ($ filename , $ flags = null )
228228 {
229- $ command = 'exec ' . \escapeshellarg ($ this ->bin ) . ' sqlite-worker.php ' ;
229+ $ cwd = null ;
230+ $ worker = \dirname (__DIR__ ) . '/res/sqlite-worker.php ' ;
231+
232+ if (\class_exists ('Phar ' , false ) && \Phar::running (false ) !== '' ) {
233+ $ worker = '-r ' . 'require( ' . \var_export ($ worker , true ) . '); ' ; // @codeCoverageIgnore
234+ } else {
235+ $ cwd = __DIR__ . '/../res ' ;
236+ $ worker = \basename ($ worker );
237+ }
238+ $ command = 'exec ' . \escapeshellarg ($ this ->bin ) . ' ' . escapeshellarg ($ worker );
230239
231240 // Try to get list of all open FDs (Linux/Mac and others)
232241 $ fds = @\scandir ('/dev/fd ' );
@@ -269,7 +278,7 @@ private function openProcessIo($filename, $flags = null)
269278 $ command = 'exec bash -c ' . \escapeshellarg ($ command );
270279 }
271280
272- $ process = new Process ($ command , __DIR__ . ' /../res ' , null , $ pipes );
281+ $ process = new Process ($ command , $ cwd , null , $ pipes );
273282 $ process ->start ($ this ->loop );
274283
275284 $ db = new ProcessIoDatabase ($ process );
@@ -285,7 +294,16 @@ private function openProcessIo($filename, $flags = null)
285294
286295 private function openSocketIo ($ filename , $ flags = null )
287296 {
288- $ command = \escapeshellarg ($ this ->bin ) . ' sqlite-worker.php ' ;
297+ $ cwd = null ;
298+ $ worker = \dirname (__DIR__ ) . '/res/sqlite-worker.php ' ;
299+
300+ if (\class_exists ('Phar ' , false ) && \Phar::running (false ) !== '' ) {
301+ $ worker = '-r ' . 'require( ' . \var_export ($ worker , true ) . '); ' ; // @codeCoverageIgnore
302+ } else {
303+ $ cwd = __DIR__ . '/../res ' ;
304+ $ worker = \basename ($ worker );
305+ }
306+ $ command = \escapeshellarg ($ this ->bin ) . ' ' . escapeshellarg ($ worker );
289307
290308 // launch process without default STDIO pipes, but inherit STDERR
291309 $ null = \DIRECTORY_SEPARATOR === '\\' ? 'nul ' : '/dev/null ' ;
@@ -307,7 +325,7 @@ private function openSocketIo($filename, $flags = null)
307325 stream_set_blocking ($ server , false );
308326 $ command .= ' ' . stream_socket_get_name ($ server , false );
309327
310- $ process = new Process ($ command , __DIR__ . ' /../res ' , null , $ pipes );
328+ $ process = new Process ($ command , $ cwd , null , $ pipes );
311329 $ process ->start ($ this ->loop );
312330
313331 $ deferred = new Deferred (function () use ($ process , $ server ) {
0 commit comments