PhpStorm 2021.1 Help

Migrate from Eclipse to PhpStorm

Switching from Eclipse to PhpStorm, especially if you've been using Eclipse for a long time, requires understanding some fundamental differences between the two IDEs, including their user interfaces, compilation methods, shortcuts, project configuration and other aspects.

User Interface

No workspace

The first thing you'll notice when launching PhpStorm is that it has no workspace concept. This means that you can work with only one project at a time. While in Eclipse you normally have a set of projects that may depend on each other, in PhpStorm you have a single project that consists of a set of modules.

If you have several unrelated projects, you can open them in separate windows.

If you still want to have several unrelated projects opened in one window, as a workaround you can attach them to the current project.

No perspectives

The second big surprise when you switch to PhpStorm is that it has no perspectives.

It means that you don't need to switch between different workspace layouts manually to perform different tasks. The IDE follows your context and brings up the relevant tools automatically.

Ps overview

Tool windows

Just like in Eclipse, in PhpStorm you also have tool windows. To open a tool window, click it in the tool window bar:

Ps migration guide tool window bar 2

If the tool window bar is hidden, you can open any tool window by hovering over the corresponding icon in the bottom left corner:

Ps tool window quick access

If you want to make the tool window bar visible for a moment, you can press Alt twice and hold it.

If you don't want to use the mouse, you can always switch to any toolbar by pressing the shortcut assigned to it. The most important shortcuts to remember are:

  • Project: Alt+1

  • Commit: Alt+9

  • Terminal: Alt+F12

Another thing about tool windows is that you can drag, pin, unpin, attach and detach them:

Ps migration guide tool windows

To help store/restore the tool windows layout, there are two useful commands:

  • Window | Store Current Layout as Default
  • Window | Restore Default Layout (also available via Shift+F12)

Multiple windows

Windows management in PhpStorm is slightly different from Eclipse. You can't open several windows with one project, but you can detach any number of editor tabs into separate windows.

Always select opened files

By default, PhpStorm doesn't change the selection in the Project tool window when you switch between editor tabs. However, you can enable it in the tool window settings:

Ps migration guide auto scroll from source

General workflows

No 'save' button

Time for some really shocking news: PhpStorm has no Save button. Since in PhpStorm you can undo refactorings and revert changes from Local History, it makes no sense to ask you to save your changes every time.

Still, it's worth knowing that physical saving to disk is triggered by certain events, including compilation, closing a file, switching focus out of the IDE, and so on. You can change this behavior via Settings/Preferences | Appearance & Behavior | System Settings:

Ps migration guide save settings

No save actions

One of the features you may miss in PhpStorm as an Eclipse user is save actions: the actions triggered automatically on save, such as reformatting code, organizing imports, adding missing annotations and the final modifier, and so on. Instead, PhpStorm offers you to run the corresponding actions automatically on commit:

Ps migration guide commit

Or manually:

  • Code | Reformat Code Ctrl+Alt+L

  • Code | Optimize Imports Ctrl+Alt+O

  • Analyze | Cleanup

If the Eclipse save action is essential for you, you can install a plugin that imitates Eclipse save actions.

Shortcuts

PhpStorm shortcuts are completely different from those in Eclipse.

The table below shows how the top Eclipse actions (and their shortcuts) are mapped to PhpStorm (you may want to print it out to always have it handy).

EclipsePhpStorm
ActionShortcutActionShortcut
Code completionCtrl+SpaceBasic completionCtrl+Space
--Type-matching completionCtrl+Shift+Space
--Statement completionCtrl+Shift+Enter
Quick accessCtrl+3Search everywhereDouble Shift
Maximize active view or editorCtrl+MHide all tool windowsCtrl+Shift+F12
Open typeCtrl+Shift+TNavigate to classCtrl+N
Open resourceCtrl+Shift+RNavigate to fileCtrl+Shift+N
--Navigate to symbolCtrl+Alt+Shift+N
Next viewCtrl+F7--
--Recent filesCtrl+E
--SwitcherCtrl+Tab
Quick outlineCtrl+OFile structureCtrl+F12
Move linesAlt+Up/DownMove linesAlt+Shift+Up/ Alt+Shift+Down
Delete linesCtrl+DDelete linesCtrl+Y
Quick fixCtrl+1Show intention actionAlt+Enter
Quick switch editorCtrl+ESwitcherCtrl+Tab
--Recent filesCtrl+E
Quick hierarchyCtrl+TNavigate to type hierarchyCtrl+H
--Navigate to method hierarchyCtrl+Shift+H
--Show UML popupCtrl+Alt+U
Last edit locationCtrl+QLast edit locationCtrl+Shift+Backspace
Next editorCtrl+F6Select next tabAlt+Right
RunCtrl+Shift+F11RunShift+F10
DebugCtrl+F11DebugShift+F9
Correct indentationCtrl+IAuto-indent linesCtrl+Alt+I
FormatCtrl+Shift+FReformat codeCtrl+Alt+L
Surround withCtrl+Alt+ZSurround withCtrl+Alt+T
--Surround with live templateCtrl+Alt+J
Open declarationF3Navigate to declarationCtrl+B
--Quick definitionCtrl+Shift+I
Open type hierarchyF4Navigate to type hierarchyCtrl+H
--Show UML popupCtrl+Alt+U
References in workspaceCtrl+Shift+GFind usagesAlt+F7
--Show usagesCtrl+Alt+F7
--Find usages settingsCtrl+Alt+Shift+F7
Open search dialogCtrl+HFind in FilesCtrl+Shift+F
Occurrences in fileAlt+Ctrl+UHighlight usages in fileCtrl+Shift+F7
Copy linesCtrl+Alt+DownDuplicate linesCtrl+D
Extract local variableCtrl+Alt+LExtract variableCtrl+Alt+V
Assign to fieldCtrl+2/ Ctrl+FExtract fieldCtrl+Alt+F
Show refactor quick menuCtrl+Alt+TRefactor thisCtrl+Alt+Shift+T
RenameCtrl+Alt+RRenameShift+F6
Go to lineCtrl+LNavigate to lineCtrl+G
Structured selectionAlt+Shift+Up/ Alt+Shift+DownSelect word at caretCtrl+W/ Ctrl+Shift+W
Find nextCtrl+JFind nextF3
Show inCtrl+Alt+WSelect inAlt+F1
BackCtrl+[BackCtrl+Alt+Left
ForwardCtrl+]ForwardCtrl+Alt+Right

Eclipse keymap

For Eclipse users who prefer not to learn new shortcuts, PhpStorm provides the Eclipse keymap which closely mimics its shortcuts:

Ps migration guide eclipse keymap

Find action

When you don't know the shortcut for some action, try using the Find action feature available via Ctrl+Shift+A. Start typing to find an action by its name, see its shortcut, or call it:

Ps migration guide find action

Coding assistance

Both Eclipse and PhpStorm provide coding assistance features, such as code completion, code generation, quick-fixes, live templates, etc.

Quick-fixes

To apply a quick-fix in PhpStorm, press Alt+Enter:

Ps migration guide quick fix

All quick-fixes are based on inspections configured in Settings/Preferences | Editor | Inspections:

Ps migration guide inspection settings

If you want to apply a quick-fix to several places at once (i.e. to a whole folder, module or even a project), you can do it by running the corresponding inspection via Analyze | Run Inspection By Name or by running the whole batch of inspections via Analyze | Inspect Code:

Ps migration guide batch inspections

Apart from outright problems, PhpStorm also recognizes code constructs that can be improved or optimized via the so-called intentions (also available with Alt+Enter ):

Ps migration guide intention
EclipsePhpStorm
ActionShortcutActionShortcut
Quick fixCtrl+1Show intention actionAlt+Enter

Generating code

The key action for generating code is Code | Generate, available via Alt+Insert:

Ps quick start generate code mac

Code completion

PhpStorm provides several different types of code completion, which include:

  • Basic completion

  • Second basic completion

  • Type-matching completion

  • Type-matching completion

  • Statement completion

By default, PhpStorm doesn't show the Documentation popup for the selected item, but you can enable it in Settings/Preferences | Editor | Code Completion | Show the documentation popup in (ms):

Ps migration guide code completion settings

If you don't want to enable this option, you can manually invoke this popup by pressing Ctrl+Q when you need it:

Ps migration guide code completion quick doc

When the caret is within the brackets of a method or a constructor, you can get the info about the parameters by calling Parameter Info with Ctrl+P:

Ps migration guide parameter info
EclipsePhpStorm
ActionShortcutActionShortcut
Code completionCtrl+SpaceBasic completionCtrl+Space
--Smart completionCtrl+Shift+Space
--Statement completionCtrl+Shift+Enter

Templates

In PhpStorm, Live templates let you insert frequently used constructs into source code.

AbbreviationExpands to ...
rqr
require "";
pubsf
public static function () { }
fore
foreach ( as $item) { }
eco
echo "";

The list of available templates can be found in Settings/Preferences | Editor | Live Templates. There you can also add your own templates or modify any existing ones.

While PhpStorm suggests templates in code completion results, you can quickly expand any template without using code completion simply by pressing Tab.

Postfix templates

In addition to 'regular' templates, PhpStorm offers the so-called postfix templates. They are useful when you want to apply a template to an expression you've already typed. For instance, type a variable name, add null and press Tab. PhpStorm will turn your expression into a if (...==null){...} statement.

To see a complete list of available postfix templates, go to Settings/Preferences | Editor | General | Postfix Completion.

Surround with live template

The surround with templates is another addition that works similarly to live templates but can be applied to the selected code with Ctrl+Alt+J.

To define your own surround with template, go to Settings/Preferences | Editor | Live Templates and use $SELECTION$ within the template text:

try { $SELECTION$ } catch ($TYPE$ $$$VARIABLENAME$) { Logger::log($$$VARIABLENAME$); $END$ }

Navigation

The table below roughly maps the navigation actions available in Eclipse with those in PhpStorm:

EclipsePhpStorm
ActionShortcutActionShortcut
Quick accessCtrl+3Search everywhereShift x 2
Open typeCtrl+Shift+TNavigate to classCtrl+N
Open resourceCtrl+Shift+RNavigate to fileCtrl+Shift+N
--Navigate to symbolCtrl+Alt+Shift+N
Quick switch editorCtrl+ESwitcherCtrl+Tab
--Recent filesCtrl+E
Open declarationF3Navigate to declarationCtrl+B
Open type hierarchyF4Navigate to type hierarchyCtrl+H
--Show UML popupCtrl+Alt+U
Quick outlineCtrl+OFile structureCtrl+F12
BackCtrl+[BackCtrl+Alt+Left
ForwardCtrl+]ForwardCtrl+Alt+Right

Refactorings

The following table maps the shortcuts for the most common refactorings in Eclipse with those in PhpStorm:

EclipsePhpStorm
ActionShortcutActionShortcut
Extract local variableCtrl+Alt+LExtract variableCtrl+Alt+V
Assign to fieldCtrl+2Extract fieldCtrl+Alt+F
Show refactor quick menuAlt+Shift+TRefactor thisCtrl+Alt+Shift+T
RenameCtrl+Alt+RRenameShift+F6

Undo

Sometimes, refactorings may affect a lot of files in a project. PhpStorm not only takes care of applying changes safely, but also lets you revert them. To undo the last refactoring, switch the focus to the Project tool window and press Ctrl+Z.

Search

Below is a map of the most common search actions and shortcuts:

EclipsePhpStorm
ActionShortcutActionShortcut
Open search dialogCtrl+HFind in FilesCtrl+Shift+F
References in workspaceCtrl+Shift+GFind usagesAlt+F7
--Show usagesCtrl+Alt+F7
--Find usages settingsCtrl+Alt+Shift+F7
Occurrences in fileAlt+Ctrl+UHighlight usages in fileCtrl+F7

Code formatting

PhpStorm code formatting rules (available via Settings/Preferences | Editor | Code Style) are similar to those in Eclipse, with some minor differences. You may want to take note of the fact that the Use tab character option is disabled by default, the Indent size may be different, etc.

Ps migration guide code style php

If you would like to import your Eclipse formatter settings, go to Settings/Preferences | Editor | Code Style | PHP, click the Show Scheme Actions button, click Import Scheme and select the exported Eclipse formatter settings (an XML file).

Note that there may be some discrepancies between the code style settings in PhpStorm and Eclipse. For example, you cannot tell PhpStorm to put space after (but not before). If you want PhpStorm to use the Eclipse formatter, consider installing the Eclipse code formatter plugin.

EclipsePhpStorm
ActionShortcutActionShortcut
FormatCtrl+Shift+FReformat codeCtrl+Alt+L

Running and reloading changes

Similarly to Eclipse, PhpStorm also has Run/debug configurations dialog that you can access either from the main toolbar, or the main menu. Compare the related shortcuts:

EclipsePhpStorm
ActionShortcutActionShortcut
RunCtrl+Shift+F11RunShift+F10
DebugCtrl+F11DebugShift+F9
--MakeCtrl+F9
--Update applicationCtrl+F10

Debugging

The debuggers in Eclipse and PhpStorm are similar but use different shortcuts:

See also, How do I start debugging?

EclipsePhpStorm
ActionShortcutActionShortcut
Step intoF5Step intoF7
--Smart step intoShift+F7
Step overF6Step overF8
Step outF7Step outShift+F8
ResumeF8ResumeF9
Toggle breakpointCtrl+Shift+BToggle breakpointCtrl+F8
--Evaluate expressionAlt+F8

Working with VCS (Git, Mercurial, Subversion, Perforce)

Configuring VCS roots

When you open a project located under a VCS root, PhpStorm automatically detects it and suggests adding this root to the project settings. To change version control-related project settings (or manually add a VCS root), go to Settings/Preferences | Version Control:

Ps migration guide vcs settings

PhpStorm works perfectly with multi-repository projects. Just map your project directories to VCS, and the IDE will take care of the rest. For Git and Mercurial, the IDE will even offer you synchronized branch control, so that you can perform branch operations on multiple repositories simultaneously (for more details, see Manage Git branches ).

Editing VCS settings

Every VCS may require specific settings, for example, Path to Git executable, GitHub/Perforce credentials, etc.:

Ps migration guide git settings

Once you've configured the VCS settings, you'll see the Version Control tool window Alt+9.

Checking projects out

To check out a project from a VCS, click Get from Version Control on the Welcome Screen, or in the main VCS menu.

Working with local changes

The Local Changes view shows your local changes: both staged and unstaged. To simplify managing changes, all changes are organized into changelists. Any changes made to source files are automatically included into the active changelist. You can create new changelists, delete the existing ones (except for the Default changelist), and move files between changelists.

Ps migration guide changes

Right-click the unversioned file or folder you want to ignore in the Local Changes tab of the Version Control tool window Alt+9 or in Project tool window and select Git | Add to .gitignore or Git | Add to .git/info/exclude.

If you want ignored files to be also displayed in the Local Changes view, click the View Options button on the toolbar and select Show Ignored Files.

Ps migration guide ignored files

Working with history

The Log tab of the Git tool window lets you see and search through the history of commits. You can sort and filter commits by the repository, branch, user, date, folder, or even a phrase in the description. You can find a particular commit, or just browse through the history and the branch tree:

Ps migration guide log

Working with branches

PhpStorm lets you create, switch, merge, compare and delete branches. For these operations, either use Branches from the main or context VCS menu, or the VCS operations popup (you can invoke it by pressing Alt+`, or the widget on the right of the status bar:

Ps migration guide vcs popup

All VCS operations are available from the VCS main menu:

ActionShortcut
Version Control tool windowAlt+9
VCS operations popupAlt+`
Commit changesCtrl+K
Update projectCtrl+T
Push commitsCtrl+Shift+K

Importing an Eclipse project to PhpStorm

Despite these differences in terms and the UI, you can import either an Eclipse workspace or a single Eclipse project. To do this, click Open on the Welcome Screen, or select File | Open in the main menu.

If you'd like to import your existing run configurations from Eclipse, consider using this third-party plugin.

Configuring PHP development environment

What configuration is needed before start?

A lot of PhpStorm features are available without any configuration right after you launch it. Still, to take full advantage of running your PHP application, you need to configure a PHP interpreter and a server.

If you plan to launch the application locally, you need a PHP engine installed and registered in PhpStorm, as well as a Web server installed, configured, and integrated with PhpStorm. You can install these components separately or use an AMP package. For more details about initial environment configuration, refer to Configure PHP development environment.

If you are going to run and debug an application directly on a remote host, the only thing you need is register access to this host in PhpStorm to enable synchronization.

How do I start with deployment to a remote host?

If you've checked out your project from the remote host, the deployment server is already configured. Otherwise, you will need to get it configured (it can be FTP/SFTP/FTPS server or mounted/local folder) on the Deployment page of the Settings/Preferences dialog. The Remote host tool window is available on the right-hand side of the PhpStorm window, which can be handy for browsing through your remote server and performing various actions.

See Deploy your application for details.

How do I start debugging?

PhpStorm comes with support for both Xdebug and Zend Debugger for debugging and profiling. There is a zero-configuration debugging workflow available, which means that to start debugging you only need to:

  • Click Start Listening for PHP Debugging Connections the Start Listening for PHP Debug Connections button on the toolbar of the IDE.

  • Place a breakpoint in code by clicking in the editor gutter next to the line.

  • Start debugging in the browser using a plugin or browser bookmarklets.

Last modified: 19 May 2021