@@ -226,7 +226,16 @@ public function openLazy($filename, $flags = null, array $options = [])
226
226
227
227
private function openProcessIo ($ filename , $ flags = null )
228
228
{
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 );
230
239
231
240
// Try to get list of all open FDs (Linux/Mac and others)
232
241
$ fds = @\scandir ('/dev/fd ' );
@@ -269,7 +278,7 @@ private function openProcessIo($filename, $flags = null)
269
278
$ command = 'exec bash -c ' . \escapeshellarg ($ command );
270
279
}
271
280
272
- $ process = new Process ($ command , __DIR__ . ' /../res ' , null , $ pipes );
281
+ $ process = new Process ($ command , $ cwd , null , $ pipes );
273
282
$ process ->start ($ this ->loop );
274
283
275
284
$ db = new ProcessIoDatabase ($ process );
@@ -285,7 +294,16 @@ private function openProcessIo($filename, $flags = null)
285
294
286
295
private function openSocketIo ($ filename , $ flags = null )
287
296
{
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 );
289
307
290
308
// launch process without default STDIO pipes, but inherit STDERR
291
309
$ null = \DIRECTORY_SEPARATOR === '\\' ? 'nul ' : '/dev/null ' ;
@@ -307,7 +325,7 @@ private function openSocketIo($filename, $flags = null)
307
325
stream_set_blocking ($ server , false );
308
326
$ command .= ' ' . stream_socket_get_name ($ server , false );
309
327
310
- $ process = new Process ($ command , __DIR__ . ' /../res ' , null , $ pipes );
328
+ $ process = new Process ($ command , $ cwd , null , $ pipes );
311
329
$ process ->start ($ this ->loop );
312
330
313
331
$ deferred = new Deferred (function () use ($ process , $ server ) {
0 commit comments