Skip to end of metadata
Go to start of metadata

Redirection Notice

Icon

 

This tutorial demonstrates how we can navigate through a PhpStorm project or codebase using the various navigation options available in the IDE.

Icon

Developer productivity can be greatly enhanced by the navigation features described in this tutorial. Together with Generating Code in PhpStorm and the various PHP Code Refactorings in PhpStorm, they allow for more focus on the job at hand, rather than having to wade through a project or execute repetitive tasks that the IDE can do for us.

The Project Tool Window is one of the many tool windows available in PhpStorm and lists all files and directories that make up our project. We can open it using the Alt+1 keyboard shortcut (CMD+1 on Mac OS X).

Using the arrow keys and Enter, we can traverse through files and directories and open them. When searching for a specific item, simply typing the first few characters will highlight all matching files and folders in the project.

The Navigation bar shows us the full path where a file is located within our project. Alt+Home (CMD+Up on Mac OS X) will bring us there. Using the arrow keys, we can navigate elsewhere in the project structure, too.

We can navigate to a class, written in PHP or any other language supported by the IDE, by pressing Ctrl+N (CMD+O on Mac OS X). This will bring up a search window where we can search using the full class name, part of it, wildcards (*) and CamelHumps (DC will search for *D*emo*C*ontroller, for example).

By pressing Ctrl+Shift+N (Shift+Cmd+O on Mac OS X), we can navigate to a file in our project. The dialog that opens is very similar to #Navigate to Class, except that this time it searches for files instead of classes. The same search options are available: full name, partial name, wildcards (*) and CamelHumps.

Whenever we want to navigate to a symbol, we can press Ctrl+Shift+Alt+N (Alt+CMD+O on Mac OS X) and bring up a similar dialog to #Navigate to Class. It allows searching for any symbol, using full name, partial name, wildcards (*) and CamelHumps.

Using Search Everywhere (Double Shift) does as its name implies: it searches everywhere, including classes, files, symbols and even menu items from the IDE. We can again search on full name, partial name as well as wildcards (*) and CamelHumps.

By hovering a symbol in code and using Ctrl+Click (CMD+Click on Mac OS X), we can navigate to its declaration. Placing the cursor on it and pressing Ctrl+B (CMD+B on Mac OS X) will do the same.


Working with code is often browsing through various locations in a file or project. We can use keyboard shortcuts (Ctrl+Alt+Left / Right (Alt+CMD+Left / Right on Mac OS X)) to navigate bak and forth between previous locations.

Within a code file, we can navigate to the next and previous method using the Alt+Down / Up (or Ctrl+Down / Up on Mac OS X) keyboard shortcuts.

Being able to #Navigate to Class and #Navigate to File is fine, but sometimes just being able to open a recent file is enough. Pressing Ctrl+E (or CMD+E on Mac OS X) brings up the Recent Files dialog in which we can select a file using the arrow keys and hit Enter to open it in the editor.

We can Navigate to the Last Edit Location (the last location in our project where we actively worked on something) using Ctrl+Shift+Backspace (Shift+CMD+Delete on Mac OS X).

By placing the cursor over a class in code, we can press Ctrl+Alt+B (Alt+CMD+B on Mac OS X) to navigate to its implementation. In case there are multiple implementations, PhpStorm lets us pick the one we want to navigate to.

As mentioned in the Working with the PhpStorm Editor Actions and Navigation tutorial, the left gutter may providing navigation functionality for certain types. Go to Derived is one of these cases: when an interface has one or more implementations, or the class we are working on has some overloads, we can click the icon in the gutter to navigate there.

We can navigate back using #Go to Super class/method.

When working on an interface implementation or on a class that is inherited from a super class or method, we can navigate up the hierarchy by pressing Ctrl+U (or CMD+U on Mac OS X).

Ctrl+H will bring up the full hierarchy in a separate tool window.

Whenever we have an open file, we can place the cursor on a symbol and press Ctrl+Shift+F7 (Shift+CMD+F7 on Mac OS X) to highlight all usages of that symbol within the file. This gives us a quick glance at our code and where the symbol is being used.

As an added bonus, PhpStorm uses different colors for reading and writing a variable, for example, so it's perfectly clear where we are assigning and where we are consuming.

Pressing Esc clears the highlighting.

Whenever we want to find out where a symbol is being used, we can place the cursor on it and press Alt+F7. This will search through all files and classes and tells us where the symbol is being used. Find Usages will also list usages in comments and so on.

Icon

Use the toolbar buttons to filter the result set if too many usages are found or if the result set has to be narrowed down.

By pressing , we can get a popup with similar information.

"An error occured on line 40 of index.php" - sounds familiar? Open the file (hint: use #Navigate to File) and press Ctrl+G to go to that line number.

Icon

Adding a colon, we can navigate to the column, too.

By pressing Alt+7 (CMD+7 on Mac OS X), the File Structure Tool Window will be opened. It shows us the structure of a file: the class, functions and their accessibility for PHP, HTML structure for HTML documents nd so on. Structure will be shown for every language supported by the IDE.

To get a quick glimpse on the current file's structure, we can also press Ctrl+F12 (CMD+F12 on Mac OS X) to show that information in a popup.

When in a file, we can search through it using the Ctrl+F keyboard shortcut (CMD+F for Mac OS X).

Icon

This search is in scope of the opened file. To search through a directory, project or configured scope, press Ctrl+Shift+F (Shift+CMD+F for Mac OS X).

Check the Working with Tabs section in the Working with the PhpStorm Editor Actions and Navigation tutorial for tips and tricks on working with tabs.

Check the Working with Bookmarks section in the Working with the PhpStorm Editor Actions and Navigation tutorial for tips and tricks on working with bookmarks.

  • No labels