I followed this tutorial to set up PhpStorm to use xdebug on vagrant: https://confluence.jetbrains.com/display/PhpStorm/Zero-configuration+Web+Application+Debugging+with+Xdebug+and+PhpStorm
When I got to step 7, and I got to this dialog, I chose my index.php file via manual selection, rather than using the radio dialog to import the mappings from my deployment server.
However, with that setting, I seem to only be able to set xdebug breakpoints in index.php, and not in any of the files / classes that index.php kicks off to do work.
I'd like to get that dialog (linked above) back, but it's not accessible through menus and invalidating the caches didn't help. Is there some way to get it to pop back up? Alternatively, is there some other way to set breakpoints in files called on by the index.php I already have mapped?
Related
I have an Codeigniter app that I am trying to debug with vim. I have xdebug installed on my server and I am using the xdebug helper extension for chrome. The issue occurs when I initiate a debug session in vim with f5 and load the page I want to debug in chrome. Vim always outputs the index.php page of my app instead of the page I loaded in chrome. I don't understand what is happening. Any help would be appreciated.
All requests to a Codeigniter site start with a call to Index.php. This file is responsible for bootstrapping the framework and ultimately routing the request to the correct controller.
My guess is that there is a setting somewhere that has xdebug stopping on the first line of executed code - line 1 of Index.php. I'm not familiar with VIM so cannot tell you where to find or how to change this setting.
You will need to set a breakpoint somewhere in the file you want to debug. In other words, in the controller that the URL is going to run.
After setting up XDebug I succeeded in debugging php files with PHPStorm that are directly accessible.
But recently I started working with CodeIgniter and I worked through this tutorial. Now I was wondering if it was possible to debug specific MVC files, controller.php for example. Because after setting a breakpoint and starting to debug the controller file with PHPStorm it of course stated 'No direct script access allowed' since I directly accessed the script.
And when accessing the file manually e.g. http://localhost:63342/01_codeigniter_tutorial/public_html/index.php/controller it just shows a 404 page instead of the usual output shown when not opening it with PHPStorm.
So I'm wondering is there a specific documentation to read through for debugging CodeIgniter or am I just handling it wrong?
Thanks to LazyOne, who enlightened me in the comments I was able to find my mistakes and the solution.
The very first reason why a 404 page was shown when browsing the site with PhpStorm, was that I was using PhpStorm's built in web server and not my Apache. And said server doesn't handle mod_rewrite rules (which simplifies URLs) so for sites using CodeIgniter it won't work. And since the scripts aren't directly accesible it's not possible by simply clicking run in PhpStorm. So we have to initiate the debug request from the outside/web browser.
Now 2 things have to be done:
PhpStorm (or your prefered IDE) has to know that a debugging process is about to happen
Using PhpStorm you have to toggle the “Start Listening for PHP Debug Connections” button.
See more in their documentation
When browsing your site as you normally would (in my case localhost/01_codeigniter_tutorial/public_html/index.php/controller) you have to set a XDebug cookie since xdebug will not automatically start a debugging session when you open a script.
The easiest way is to install a Browser add on since you only have to click a button (I used The easiest XDebug for FF)
Read this for more information
After everything has been set up, you only need to refresh your page and the IDE should receive your debugging request.
Eclipse PDT is very slick, but here's my issue, Re: Launcher (run configurations)
I'm trying to keep things very clean, concise on my local machine (with WAMP stack) and I have a number of virtual hosts configured, that keep my URL's easy to use.
In eclipse, I set up PHP servers to correspond with these Vhosts.
Since I have existing code, I'm usually setting up a new project 'from existing sources'.
Then when I try to 'run', I get URL auto-generated like this; with the Project name in it:
http://MyVhost/MyProj/testing.php
And what I really want is:
http://MyVhost/testing.php
I find myself doing a lot of editing and adjusting of the servers and run configurations, before I can get the URL that works. Any recommendations ?
You can create a new Run Configuration Run->Run Configurations and as long as you have setup your virtual hots as servers, you can untick 'Auto Generate' option under URL and enter you URL manually for each project. So even if you point to different files in your project, it won't matter because Eclipse will use your manually entered URL. Save these and then you're done!
The path part of the autogenerated URL is the Base Path (which defaults to / + project name) + the path of the file inside the project location. You can set the Base Path to / in Project | Properties | Debug . It applies to Run configurations as well. If you always use the documentroot of the site as the project location, it will work.
I ran across something similar where if I had a vhost named "test" I wanted to run everything for that project as...
http://test/<whatever_else>/
Here is my 3 step how-to to solve it, though I am not sure of any unintended consequences other than zend debugger not working.
From Eclipse, go to Windows/Preferences
Go to PHP/PHP Servers
Change Default PHP Web Server from http://localhost to http:/
The project will append the second slash and your project name if you just let it auto-generate.
Hope that helps someone. Helped me a ton.
You can modify the org.eclipse.php.server.ui plugin to get it the way you want.
Use the Plugin devlopment perspective of Eclipse to modify the plugin. The dialogs are available in
/org.eclipse.php.server.ui/src/org/eclipse/php/internal/server/ui/launching/PHPWebPageLaunchShortcut.java
/org.eclipse.php.server.ui/src/org/eclipse/php/internal/server/ui/ServerLaunchConfigurationTab.java
https://vsubhash.wordpress.com/2013/01/26/fix-for-url-auto-generate-bug-in-eclipse-php-pdt-plugin/
I've been reading through the docs and testing out what i can.
I've installed PHP, Eclipse + PDT, IIS settings etc. - I'm reasonably sure they are all set and should work.
Now I create a PHP Project, add a newfile.php, basic code like :
<?php
echo "hello";
Now I right click the file,Run as -> Web Page and i get a 404.
Eclipse has tried to launch http://localhost:80/Php1/newfile.php
IIS has no virtual or physical directory so the request fails.
Should Eclipse/PDT have done this mapping? Or do I need to? or should I create my projects under c:\inetpub\wwwroot
Eclipse / PDT does not configure your webserver for you. It looks like it's assuming that your document root is your workspace, so you could put all your projects in your wwwroot if you wanted to. You don't need to use the Run As dialog though, as long as the files are somehow visible to IIS.
Personally I like to either make a vhost per project, or use symlinks to bring the project directories into the wwwroot.
Bit of an obscure one this. My setup is all running on my local Windows machine; I've got NetBeans IDE installed, a local XAMPP server with XDebug running, and an installation of Moodle with some custom addons in the mod directory.
I can happily create breakpoints in PHP pages (including the main Moodle ones), but any breakpoints I place on php files in the mod directory never fire (on my mods, or any of the inbuilt ones). I thought Moodle might be doing some "magic" to display files in the mod directory, but my browser shows the url as http://localhost/moodle/mod/view.php - and that's the file I've set my breakpoint in.
Has anyone got any experience with debugging Moodle addins, or could possible point me in the direction of how to troubleshoot the breakpoint not firing? I've tried the Moodle site, but can't find anything relevent.
Actually, I think I've figured it out. If I tell it to debug that particular file it will 404 (it doesn't put the directories in, guess it's a bug), but if I then manually go to http://localhost/moodle/mod/view.php?XDEBUG_SESSION_START=netbeans-xdebug (which errors, no parameters are being passed in), and THEN manually navigate to Moodle then my mod breakpoints fire correctly.
All very bizarre, but it seems to be a usable workaround. I'm guessing the mods are running under some kind of different PHP session.
I'll keep this answer here in case anyone else has this bizarre problem.