2

Given the following scenario:

controller@method_a spawns a process (Symfony Process object) asynchronously, controller@method_b needs to interact with the process

How would you implement sharing the Process object?

Things I've went over:

  • controller properties don't persist, as with each request the controller gets reinstantiated
  • Session can't store complex objects, and serialization would take the soul of it
  • database can't store complex objects either

edit:

To the serialization issue:

    $process = new Process("dir");
    $process->start();
    $x = serialize($process);
    dd($x);

If I remove the $process->start(), it does not fire Serialization of 'Closure' is not allowed. But I can't do anything with a handle for a process that's not started.

Rápli András
  • 3,869
  • 1
  • 35
  • 55

1 Answers1

0

I guess the only option here is to serialize an object and persist it somewhere (DB, session, file). In next request, pull it and unserialize.

Alexey Mezenin
  • 158,981
  • 26
  • 290
  • 279