Setting up phpstorm 4 with XAMPP on Windows 7 - windows-7

I need help setting up phpstorm (4.0) with XAMPP which is at the default location c:\xampp\htdocs. I create all my projects at c:\xampp\htdocs\projectname.
Here are the things I have already done:
Setup the PHP interpretator by going to settings and then PHP (main menu)
Go to PHP > Servers and then
To setup run configuration I have the done the following:
Now when I run using the above configuration it just takes me to localhost in my browser, instead of the file I am editing (http://localhost instead of localhost/myproject/myfile.php).
What am I missing? I read the help topics of phpstorm and googled a lot but still couldn't figure it out.

Turns out you don't need to set up run configuration. The answer lies in setting up the mapping in the deployment tab in settings.
(assuming that you are creating your projects in c:\xampp\htdocs)
To do that go to settings (Ctrl + Alt + S) and then choose deployment:
Under mappings tab, it should look like this:
And after that you can view the file in the browser through this menu:

Check the answer to this question. If you need to debug, the recommended way to do it is zero configuration debugging.

Related

PhpStorm How to correctly configure upload shortcut?

I finally bought the PhpStorm licence. Been using it for two years and, since their doing a great job, I had to play the game and be honest.
Now I'm faced with a problem, previously I had the perfect configuration that I don't have anymore.
Every project is linked to a ftp remote host. When I edited a file locally and save with ctrl + S, it saved the file locally without uploading it.
To upload I configured the explicit save on CTRL + Maj + S (In tools > Deployment > Option).
It was perfect!
With the new version, I can't find a way to do that. I tried updating the shortcut in the settings but it always stays "On explicit save action (Ctrl + S)".
I'm missing something and it's driving me crazy... (loosing all my ftp configuration in the update did not help).
That was actually a bug: https://youtrack.jetbrains.com/issue/WI-21962
The behavior you're currently experiencing is expected.
You can assign Ctrl+S to Other | Save Document action in Keymap - this would save currently opened file only and wouldn't trigger auto-upload.

Xdebug with PHPStorm 8 -- opens WRONG file at non-existing breakpoint

I am having trouble using Xdebug with PHPStorm. I have searched Google, etc.
I have Xdebug setup on a remote host with my local files mirroring the remote host. I am using the Xdebug Chrome extension.
When I run the debugging through PHPStorm, it OPENS a file and shows a blue-highlighted breakpoint that does NOT exist at that file. It will stay there until I hit "resume" multiple times until I get to the file I actually want to debug. VERY annoying because then the session on Chrome timesout, so I can't debug.
I do not see any code that says xdebug_break(); and I never added a breakpoint to that file. In other words, there are no red markings at the left of the line numbers.
What is going on and how do I fix this? Has anyone else come across this problem?
I have tried skipping and ignoring the file ... still does not work! Yes, I have also viewed breakpoints through a separate window and it does not show the breakpoint that apparently exists.
Check the configuration on PHPStorm stop at first line property and disable it
After that go to Run >> Break at first line in PHP scripts
Try turning it ON and OFF few times. Sometimes it is get stuck in between: showing OFF but in reality it is ON.
This is a well known issue Read: https://youtrack.jetbrains.com/issue/WI-17389
I was having the same problem with my PHPStorm/xdebug config. It turned out I had the path mappings wrong when I mapped the root of the local file directory to the Absolute path on the server - Settings->Languages and Frameworks -> PHP -> Servers.
I fixed the mapping and the system is behaving predictably once again.

How to set up remote debugging for symfony2 with phpstorm and xdebug

Problem:
I want to be able to debug my symfony2 project. I would like to be
able to set a break point in my code, run remote debugging and be
able to step through all the break points in my code as I interact
with my application.
Background information and current setup:
The IDE I am using is phpstorm.
Apache and mySql server are running on my vmware player.
Xdebug is installed on vmware player.
I currently connect to my project through my vmware players ip
(i.e 172.16.48.1/app_dev.php). At this point I interact with my
application normally and develop.
What I have done so far
I followed the tutorial but have not had any luck.
I really confused by most of the tutorial but followed it as best as I could. I do not think the bookmarklets were working correctly when following the instructions.
I also watched a webinar or two on remote debugging and it still was not completely clear to me what I need to do to step through my code.
Question:
Can someone provide a step by step tutorial of what I need to do to
setup remote debugging so that I can launch some remote debugging
session through phpstorm that will open my web application and as I
navigate through my web application my break points will be hit?
i've just finished setting up my local symfony2 app and phpstorm debugging with Chrome, here is what i've done:
1) config xdebug in php.ini on the server and restart web server (or php-fpm):
[xdebug]
zend_extension="**location to xdebug**/xdebug.so"
xdebug.remote_enable = 1
; use port 9009 because php-fpm uses 9000 by default
xdebug.remote_port = 9009
xdebug.idekey = PHPSTORM
2) install xdebug extension
https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc
3) setup xdebug exteions. in chrome://extensions find Xdebug helper and click options. there select IDE key to PhpStorm. (this will essentially set xdebug.idekey to PHPSTORM for that particular session)
4) now the trickiest part, connecting from PhpStorm.
you have to setup PHP Remote Debug debug configuration.
in the toolbar, next to the debug button, you have drop down field with the first option Edit configuration. it opens Run/Debug Configurations.
there click the + button and add PHP Remote Debug.
specify your name, server and Ide key = PHPSTORM.
click Apply and Ok (i never know which one so i always click both, just in case)
now the dropdown in the toolbar will show your newly set remote server, run button (green arrow) will be disabled.
click Start Listen for PHP Debug Connection
click that green bug icon to start debugging
Debug view will open with 2 tabs: Debugger and Console (selected by default)
change the tab to Debugger and you will see: "Waiting for incoming connection with the ide key 'PHPSTORM'"
open your browser
navigate to your server url
activate Xdebug helper extension (clicking on that gray bug in the url bar) it will turn green
to check that everything is ok, open Chrome console, tab Resources -> Cookies -> your server. and verify that cookie XDEBUG_SESSION with value PHPSTORM was created (this is what actually activates xdebug remote debugging in php)
now refresh the page and quickly alt-tab back to PhpStorm (or arrange your windows so you can see PhpStorm while refreshing browser)
in your Debug view and Debugger console you will briefly see "Connected"
TADA!
create couple of break points in controller (dont use AppKernel.php or other symfony2 specific files as those get compiled and are not called, even in dev mode)
added 5.1.2015
official tutorial can be found here:
https://confluence.jetbrains.com/display/PhpStorm/Profiling+PHP+applications+with+PhpStorm+and+Xdebug
Everything worked, up to the point where I set a breakpoint. Since Symfony2 is a front controller, it doesn't know which corresponding file matches the breakpoint.
I tried to setup path mappings, but to no avail.

PHPStorm / debugger not stopping at certain breakpoints

I've set up XDebug (2.2.1) and PHPStorm-IDE (Mac OS X 10.7.5) with standard LAMP stack for Mac OS (Apache 2.2.22, PHP 5.3.15).
/etc/php.ini
[xdebug]
zend_extension=/usr/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so
xdebug.file_link_format="txmt://open?url=file://%f&line=%1"
xdebug.remote_enable = On
xdebug.remote_autostart = "PHPSTORM"
xdebug.var_display_max_data = 1024
xdebug.dump.GET=*
xdebug.dump.POST=*
xdebug.show_local_vars=On
xdebug.dump.SERVER=*
xdebug.dump_globals=On
xdebug.collect_params=4
I followed these two tutorials and it works in 99% of my project files:
http://blog.jetbrains.com/webide/2011/03/configure-php-debugging-in-phpstorm-2-0/
http://blog.jetbrains.com/webide/2011/02/zero-configuration-debugging-with-xdebug-and-phpstorm-2-0/
I use Zend Frameworks MVC architecture. I am able to stop at breakpoints in most of my controller classes, but in some other controllers PHPStorm ignores all of my breakpoints.
Do you have any suggestions? How can I debug the debugger? What kind of configuration error could cause that?
Thanks for your help.
This almost has to be the result of mismapped paths in phpstorm. You can configure paths in Settings->PHP->Servers. I ran into a similar problem and all I had to do was to set the correct absolute path on the server (where xdebug is running) in the mapping for the root of my code in phpstorm. e.g. c:\my\code\lives\here\on\my\dev\box => /myserver/my/code/lives/here/on/my/actual/server.
Here is a more complete solution, and some tips on debugging XDebug in general:
Add a remote log file to your xdebug settings: xdebug.remote_log = /path/to/logs/xdebug.log
Restart apache
Tail the log (I'm assuming you can do this in OSX)
tail -f /path/to/logs/xdebug.log
--You might see something obviously wrong by keeping track of the log contents the next time you try to debug a page. If so, just do whatever you need to do. If not, let's still assume it's a mismapping of paths and continue to try to fix that:--
Set a breakpoint where you know PHPStorm/XDebug will actually stop and make it stop there. In a lot of places on the web people report index.php being the easiest place to make PHPStorm actually stop at a breakpoint for the first time.
In a file that you can't get PHPStorm/XDebug to stop in, set and unset a breakpoint while PHPStorm is stopped at the breakpoint in the index.php file. You should see lines in your xdebug log file that look like this:
<- breakpoint_set -i 19 -t line -f
file:///myserver/my/code/lives/here/on/my/actual/server/file.php -n
159
->
See if the file actually does live where XDebug is looking for it e.g.
tail /myserver/my/code/lives/here/on/my/actual/server/file.php
If the file doesn't actually live there, adjust the path mappings in your PHPStorm settings until PHPStorm is telling XDebug to look at files that actually exist. e.g. if XDebug had said file=/mysrver/my/code/lives/here/on/my/actual/server/file.php, then in step 6 you would have noticed the file didn't exist on the server, and then you might realize "oh oops I spelled myserver wrong in the path mapping", and fixing the spelling in PHPStorm would then probably fix the issue.
This is a bit of an old thread but hopefully this will help someone eventually :)
OK, I had the same problem and dug around the PHPStorm bug tracking and also their dev forums.
It turns out that you need to make sure that the path to the file in which breakpoints don't work are exactly as they are (lower/upper case wise) on your MAC. I just migrated a project from Windows with mixed upper/lower case folders and file names on the drive and different cases in the require_once directives.
Once I made sure the path in the require_once matched the case on the disk, then my breakpoints started to work again!
See here http://devnet.jetbrains.com/message/5488439
This usually means the controllers aren't called.
If it does work for certain controllers (within the same project) it just means: the code wont get called.
So get a few steps up to see the correct controllers is called. (e.g. from the dispatch and then dive into until the controller gets loaded).
And is it possible that you work remotely (e.g. from local to another server). Than it can take a little time before it the code is placed on the server. Just wait a few seconds and than try again. Since how can it break on a point that it doesn't know?
Hope this helps to get you started to debugging it.
This happend to me too several times. Usually the debugger's configuration is the reason. You have to set the path mappings of the debug server correctly under "Run > Edit configurations".
Possible reasons for NOT stopping at breakpoints:
the IDE refuses the debug connection requests coming from the remote server. The telephone icon has to be green (Run -> Start Listening For PHP Debug Connections) in order to avoid this.
all the breakpoints are muted. Turn breakpoint muting off.
the Suspend checkbox of a particular breakpoint is not checked. Check them one-by-one in Run -> View Breakpoints. The tick means "Suspend Execution", not "Suspend the breakpoint", as one may think. (The current version of PHPStorm I use seems to be buggy, if I check the Suspend checkbox then it doesn't take effect yet. I have to click another breakpoint and then click back in order to "submit" checking the checkbox.)
If you want to debug a script invoked from a browser then the browser should set a cookie called XDEBUG_SESSION with the value of the idekey. You can initiate it by extending the URL this way: http://192.168.99.100/?XDEBUG_SESSION_START=PHPStorm. Be aware of the expiration of the cookie which is only one hour. There are useful browser add-ons for easing handling the debugger cookie. See https://xdebug.org/docs/remote#starting for more.
the individual breakpoint is not Enabled. Check them one-by-one in Run -> View Breakpoints.
the individual breakpoint has some condition that doesn't get met. Check the Condition setting of the breakpoint in Run -> View Breakpoints.
there is some mapping issue between the remote server and the IDE. When you set a breakpoint in the IDE then it sends the remote server that the execution should stop at the Nth line of the F file. There is a mapping between your local files and the files on the remote server. The mapping is defined in the IDE at the following places:
on the Path mapping field of the Preferences -> Languages & Frameworks -> PHP page
on the Preferences -> Languages & Frameworks -> PHP -> Servers page
If these mappings are incorrect, for example, the local F1.php is mapped to the remote F2.php by accident, then you may have problems. If you set a breakpoint at the line #N in your local file F1.php the server will stop the execution only if the execution reaches the line #N of file F2.php (rather than that of F1.php). If this is the problem then you still can debug your code if you turn on the Run -> Break at first line in PHP scripts flag. Be aware of the different case sensitivity in directory and file names of your development operating system versus that of the remote server!
The IDE is not receiving debug connection requests from the remote server due to some network setting issues. Check the Preferences -> Languages & Frameworks -> PHP -> Debug page whether the IDE is listening on port 9000 for XDebug, check whether it Can accept external connections, and so on.
The XDEBUG-related settings of the remote server are incorrect. I use the following settings in my php.ini
.
xdebug.default_enable = 1
xdebug.remote_enable = 1
xdebug.remote_connect_back = 0
xdebug.idekey = "PHPStorm"
xdebug.remote_autostart = 1
xdebug.remote_host=192.168.1.26
You should set remote_host to the IP address of your development computer, or you can omit the whole line if your server is on localhost.
Plus, I set the following environment variables:
export PHP_IDE_CONFIG="serverName=halmaiXdebug"
export XDEBUG_CONFIG="idekey=PHPStorm"
where the value of the serverName is the Name of the server I defined on the Preferences -> Languages & Frameworks -> PHP -> Servers page in the IDE.
UPDATE: Too old PhpStorm version also can cause breakpoint issues. With PHP 7.4 on the server and PhpStorm 2018.2 locally, the execution stopped at the first instruction but not at any further ones. After upgrading to a newer PhpStorm version (2020.1), it works as expected.

Why does WebStorm's LiveEdit not work in Chrome?

I am exploring WebStorm's trial version and would like to use the LiveEdit features.
I am not able to use the LiveEdit features after performing the following actions:
Made sure that LiveEdit is turned on
Installed the Chrome extension
Restarted the browser after installing the extension (I still suspect it is not required)
Run the HTML page in chrome
When I modify the HTML body, I don't see the changes reflected in Chrome.
I read on a forum that netty is not required.
Do we need it?
What else do I need to configure so that I can use the LiveEdit feature?
PS: I am using WebStorm 5.0.
Do you happen to have IntelliJ open by chance?
The point is that the port, 63342, is 'seized' by another app (even if it has nothing to do with HTML debugging).
When the port is busy, LiveEdit tries the next one, 63343. If you right click the JB icon on Chrome, choose Options, increment the port by one, and press Apply, you will magically connect. I wish Jetbrains would have bothered to inform the user what is the port that they are currently attempting to use.
In my PC it happened when I had Mac on. Either one of the following worked:
1. Kill IntelliJ IDEA (that was also open) and try again
2. Increment the port by one as I mentioned above.
I had to go to Run -> Debug (CTRL+F5 on Windows)
What helped in my case was activating "Can accept external connections" under the Settings -> Build, Execute, Deployment -> Debugger
WebStorm Settings
More details as requested:
Installed the JetBrains IDE Extension for Chrome
Make sure the LiveEdit Plugin is installed and activated (Settings -> Plugins)
Make sure "Can accept external connections" is checked (Settings -> Build, Execute, Deployment -> Debugger) AND Port is the same as in the Chrome Extension
Make sure Update ist set to "Auto in (ms)" e.g. 300 (Settings -> Build, Execute, Deployment -> Debugger -> Live Edit)
In my case live edit was just disabled (for some reason)
For anyone googling this thread, LiveEdit is now supported without a plugin. Just go into settings and uncheck "Use JetBrains IDE Support extension for debugging and Live Edit".
Without the extension, the debugging and live edit are more reliable based on my personal experience.
I couldn't make Chrome and Webstorm to link with each other. Chrome plugin was set to 63343 port or something like that.
I am on Windows. I opened command line with administrator privileges and typed:
netstat -a -b
to see all programs and ports they are listening to. I then found first entry regarding WebStorm.exe and saw that it was listening on port 30897. I set that port number in my chrome plugin options, and everything worked.
A quick fix: in the Chrome addon configuration, use the ip 0.0.0.0 for the host.
Turning off the automatic connection configuration from Internet Explorer properties worked for me smoothly. IE is the boss.

Resources