I’m testing some database related functions in interactive mode.
The first thing I did is to include the testing file, let’s say database.php
Then I can make change to the database by a function call.
The question is, when I make any changes to database.php, I have exit PHP interactive mode, re-enter, include the testing file again.
I’m seeking a way to reload the include file during the interactive mode.
Advertisement
Answer
There is no simple method of doing this cause PHP is not built for this job, but there are some things you can take a look at as it might do the job for you. However this all depends on what is in your database.php
.
Create a simple function like reset
and use PHP’s runkit functions to update your include.
If your database.php
contains functions, you need to remove the functions before including it again. If your file has a class defined in it you could try the import function and just call the function that does all this for you but in the end this is all manual labor and it might be simpler to look at other alternatives.
I for one use a auto refresh timer in my browser to refresh the page every # seconds. However I have two screens which makes using this method much easier.