Skip to content

Instantly share code, notes, and snippets.

@Potherca
Last active February 9, 2023 18:30
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Potherca/b4bc776c5e71065b174f49c6696754e2 to your computer and use it in GitHub Desktop.
Save Potherca/b4bc776c5e71065b174f49c6696754e2 to your computer and use it in GitHub Desktop.
HOWTO: Skip files outside PhpStorm project in Xdebug sessions

Introduction

In PHP development environments, it is not entirely uncommon to use an auto_prepend_file to add development-specific functionality to an application. Usually such a file is used for several projects at the same time. This means the prepend file resides somewhere in a more high-level location.

A more common practice is to use Xdebug te debug PHP code.

When combining these two with PhpStorm this will lead to the prepend file being marked as "not mapped".

Problem

Every time a debug session is started, it will stop at the first step. This is because the prepended file is not part of the project. PhpStorm will stop the debugger in order to ask the user to add a mapping to the prepend file.

It is possible to manually skip/continue (or step through) the prepend file but this gets boring real fast.

It would be nice if the file could just be skipped, but how do we do that?

Solution

Although PhpStorm has the ability to skip paths, this only sadly only works for file within the project.

But there is another solution that will work for files living outside of the project.

In the settings, under Languages & Frameworks > PHP > Debug, unset the following settings:

  • Break at first line in PHP Scripts
  • Force break at first line when no path mapping specified
  • Force break at first line when a script is outside the project

Screenshot of PhpStorm debug settings

Now, whenever a debug session is started, it will skip straight to the first breakpoint.

Happy times!

@eltoma-alexkuc
Copy link

Very useful! Thank you!

@duartedanilo
Copy link

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment