superdee72 superdee72 - 1 year ago 35
PHP Question

Is there a way to start and stop Php code at a specific point using eclipse?

I am developing a script that takes between 2-5 minutes to run. I am developing functionality about 4 minutes into the script, so while I develop I have to run the application again and again to get to the part I'm developing which can be quite time consuming.

Is there a way to start the script from where I want to too (with all the internal data such as arrays and variable saved) and then just step through the part of the code I'm developing?

Please let me know if there is a good solution for this, I am using Eclipse running on my Wamp Server and I am sure someone has come up with a solution.


Assuming that the variables generated in the first 4 minutes are expected to remain the same then you can try something like this:

First round

// 4 minutes of code later...

file_put_contents('4_minute_snapshot.json', json_encode(get_defined_vars()));


// new functionality testing

Subsequent rounds

$json_unique_identifier = json_decode(file_get_contents('4_minute_snapshot.json'));

foreach($json_unique_identifier as $k=>$v)
    $$k = $v; // $$k is not a typo :-)
unset($v, $json_unique_identifier);

// new functionality testing

Note, if you have resources or other things that are not json encode-able such as classes then you should identify those an manually set them just before the // new functionality testing part.