Note that there are some explanatory texts on larger screens.

plurals
  1. PONetbeans and PHPUnit Skeletion Generator: No such file or directory
    text
    copied!<p>I use netbeans 7.2.1 and newest phpunit. When I want to generate a unit test in netbeans by right-clicking on the php class then Tools-> Create phpUnit test the Skeleton generator throws an error: No such file or directory.</p> <pre><code>require_once(/sharedResources/connection.inc.php): failed to open stream: No such file or directory </code></pre> <p>The issue is that the path displayed in require_once is wrong. It is generatedliek this:</p> <pre><code>$sharedResources = getenv("DOCUMENT_ROOT") . "/sharedResources"; </code></pre> <p>and should resolve to the absolute file path. This works fine when application is running in apache. However it seems that getenv("DOCUMENT_ROOT") is just wrong when running from netbeans. My question is how I can set it correctly? My application is under </p> <pre><code>getenv("DOCUMENT_ROOT") . "/MyApp"; </code></pre> <p>and the file I'm creating a test for is in </p> <pre><code>"MyApp/services" </code></pre> <p>Under Project properties there is an option web root but it is greyed out and it is impossible to set it to a folder one level higher than your application.</p> <p>How can I solve this?</p> <p>EDIT:</p> <p>Further clarification:</p> <p>I initially had a relative filepath to sharedResources which did not work also. the I changed to this one and of coruse ti makes sense it is not working as DOCUMENT_ROOT is set by apache and hence not set when running in netbeans. So a temprary fix is to add</p> <pre><code>$docRoot = getenv("DOCUMENT_ROOT"); if(empty($docRoot)){ putenv("DOCUMENT_ROOT=C:/xampp/htdocs"); } </code></pre> <p>to the head of every class. of course that is not a very practical or good solution. I would need to tell netbeans to set this environment variable or to use correct relative path.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload