When using mod_rewrite to rewrite URLS, Netbeans IDE is unable to debug correctly. I have used wireshark to monitor the
communication with xdebug and it appears that xdebug is providing the correct file path for php files so Netbeans could
use this path to display/debug the appropriate files.
I am using Apache2 with mod_rewrite as provided in Ubuntu 8.04 distribution.
1. Install Apache2 and enable mod rewrite (sudo a2enmod rewrite)
2. Modify "AllowOverride" directive for DocumentRoot in /etc/apache2/sites-enabled to allow uri rewriting and restart apache
3. Create file .htaccess in root source directory with following text
RewriteCond $1 !^wwwroot/
RewriteRule ^(.*)$ wwwroot/$1 [L]
4. Create new Netbeans PHP Project titled "testproject" with index.php in root source directory.
5. Select "Copy Files to New Directory" and enter directory titled "testproject" in DocumentRoot
6. Modify index.php in the root source directory to denote it's location when viewed (echo ("Root index file") )
7. Create subdirectory in sources directory called wwwroot
8. Create index.php file in wwwroot and modify to denote its location.
9. Leave or set "Stop at first line" in Tools -> Options -> PHP
10. Run debugger
Netbeans will stop at the first line and display the index.php from the root directory. Browser will display the
appropriate index.php from wwwroot when continuing.
Apologies if this is a dupe. I did find the following thread in the forums but couldn't find a logged issue for it.
I have to extend this issue:
Websites that make heavy use of Mod Rewrite with non-existing subfolders cannot be debugged at all, since in the Project
"Run" Settings you can only specify an "Index File" that is existant.
It would probably help if the specified index file and the opened url for the browser could be different (although this
is possible by changing the global browser arguments, which is rather hackish and not cross project compatible).
In my opinion this has a higher priority than P3, because all frameworks with mvc use htaccess rewriting nowadays and
many other projects do so too (wordpress, typo3 for example) and its not really possible to work around this.
OK, thanks, so let's make it P2
Shouldn't this bug be marked as P1 as it blocks 140918 which is P1?
Quality Engineering: no, this isn't P1 at all, P2 is ok for this bug. Btw., #140918 is P1 enhancement not P1 defect - and that's kinda difference.
Just a quick comment. You can easily debug PHP that requires mod_reqrite (for example Zend Framework) you just need to set the project debug settings to 'Do Not Open Web Browser', then install an Xdebug plugin into your browser (e.g. 'Xdebug helper' for chrome). Press 'Debug Main Project' then start the Xdebug plugin in the browser, refresh the page you are on. This works fine.
I realise this is a bit of a ramble, but seeing as mod_rewrite is used in almost all PHP frameworks I think bundling an Xdebug plugin with Netbeans would be a great idea. That is, it solves this bug.
Or maybe the documentation needs updating?