How to run/debug PHP scripts in PHPStorm?


Is it possible to run PHP scripts(not web applications) in PHPStorm for debug/test purposes?

For example, a very simple php script like below:


$mystring = '';
$find = 'HG1';

$pos = strrpos($mystring, $find);
if ($pos === false) { // note: three equal signs
echo "not found \n";
echo "found! \n";

Joao Paulo
Comment actions Permalink

Hi Andriy,

Thanks a lot for your answer.

I will go through the links you posted and let you know if I still have questions on it.


Best regards,

Joao Paulo

Comment actions Permalink

It used to be that you could press Ctrl-Shift-F10 (not Alt-R as I previously stated, that was a customization) and it would offer the possibility to run it as PHP or as JavaScript (that is, it would open in the browser). That choice seems to be gone in a recent version; is there any way to get it back? It's a hassle to create a manual run configuration for a single script just to run it in the CLI. Can I set it to run in the CLI by default somehow?

Comment actions Permalink


Ctrl+Shift+F10 still works for me (I'm on Windows 10 using default/Windows-based keymap).

I do not have any Run/Debug configuration created for this file and it offers me to choose how to run it:


Alt+Shift+F10 shows ALL available configurations (with current one preselected) and also offers to create new ones for current file (at the bottom):

Comment actions Permalink

Aha - with Alt-Shift-F10 I discovered that those options do not show up for files that are in a directory which is marked as "excluded". The behavior toggles to working and non-working along with changing this attribute of a directory.

That is you can not choose the run context with Control-Shift-F10, and for those files Alt-Shift-F10 only shows the "2. file.php (JavaScript...)" option in the configurations popup. I am not sure if I excluded this directory recently, but I did re-clone this repo recently and it's listed in the .gitignore file (if that matters at all).

I guess the (interim?) solution is to just select "Cancel Exclusion" for this directory under "Mark Directory as".


Please sign in to leave a comment.