In debugging, changes in files content caused by the php script don't show up until the end of debug session

I installed PHPStorm Ver 9.0.2 and also XDebug. I configured everything according to the documentation. The enviroment is Windows 7, Xamp. Everything seems to work fine exceprt one thing.
When working with "Step Over" and the code writes something in some other text file, this text is not seen until the debug session is ended.
I attached the phpino() output as an html filr.
Can someone advise please?
Regards
I. Sher



Attachment(s):
phpinfo().html.zip
7 comments
Comment actions Permalink

Hi there,

How do you work with the file? What functions do you use?

Maybe they require closing the file before file buffer will be flushed to the disk (new data will appear in actual file)?

0
Comment actions Permalink

Thx
Few details regarding your answer.
1. I use fopen() to open the text file and fwrite() to actually write text.
2. In the past I used another IDE, Netbeans with the same script and I saw the new text immediatly after the fwrite() execution.
Regards

0
Comment actions Permalink

Seems to work just fine here on Windows 7 x64; PhpStorm 9.0.2; PHP 5.5.29 & 5.6.13; xdebug 2.3.2; both via CLI and browser (IIS as web server with PHP via FastCGI)


File size/timestamp does not change in Windows Explorer (unless you click Refresh) untill script is waiting on breakpoint, but file shows new content if opened fresh in text editor (Notepad++) at any time. At the same time Grep Console's tail functionality and keeping file opened in Notepad++ showed/detected new content when switched to them (while waiting on breakpoint in IDE).

I've used this sample code #1 from http://uk3.php.net/manual/en/function.fwrite.php

<?php
$filename = 'D:\TEMP\test123.txt';
$somecontent = "Add this to the file\n";

// Let's make sure the file exists and is writable first.
if
(is_writable($filename)) {

    // In our example we're opening $filename in append mode.
    // The file pointer is at the bottom of the file hence
    // that's where $somecontent will go when we fwrite() it.
    if
(!$handle = fopen($filename, 'a')) {
         echo "Cannot open file ($filename)";
         exit;
    }

    // Write $somecontent to our opened file.
    if
(fwrite($handle, $somecontent) === FALSE) {
        echo "Cannot write to file ($filename)";
        exit;
    }

    echo "Success, wrote ($somecontent) to file ($filename)";

    fclose($handle);

} else {
    echo "The file $filename is not writable";
}
echo "DONE\n";
0
Comment actions Permalink

Ok
I found a way how to reflect changes while still in the debug session.
The trick that works for me is to pass the focus to another application and than to get back to PHPStorm.
To my view its something inside the IDE configuration.
IS there any isea?
Thx

0
Comment actions Permalink

So .. you are opening that file in IDE and not externally?

If so -- try "File | Synchronize" -- it will re-read project files looking for changes -- that's what happens when IDE receives focus when coming back from another application.

If that file is some soft of log file -- try Grep Console plugin -- it can watch for a file changes and show them in separate tool window (tail).

0
Comment actions Permalink

Thx Andry
I tried the File->Synchronize and it works.
Problem is that its not a kind of a log file, and the second part of you respond is not so appropriate.
Is the another solution, like auto synch every line in the debugger?
Regards
I. Sher

0
Comment actions Permalink
Is the another solution, like auto synch every line in the debugger?

There is no such functionality.

There were no use case for that -- normally, if you write something into a file and have that code in ordinary php file, you would just save the text into some intermediate variable first (which you can easily inpect in debugger) and only then write it into actual file. Once you finish with debugging such code .. you just remove intermediate variable so that stuff gets written into a file directly.

0

Please sign in to leave a comment.