Phpstorm manual

1571

Click here to load reader

description

Phpstorm manual

Transcript of Phpstorm manual

  • PhpStormPhpStorm is a new Integrated Development Environment for the PHP developers, built on top of IntelliJ IDEAplatform. PhpStorm inherits all the web-related functionality of IntelliJ IDEA for editing PHP, HTML, CSS,JavaScript, XML, working with VCS, SQL, plus adds advanced support for the other tools specific to webdevelopment.

    PhpStorm brings you the following advanced features:

    Intelligent Editor: for PHP, HTML, CSS, JavaScript, and XML, which includes syntax highlighting,documentation lookup, and refactorings.

    Error-Free Coding: on-the-fly code analysis, error highlighting and quick fixes.

    Project and Code Navigation: specialized project views, file structure views and quick jumping betweenfiles, classes, methods and usages.

    VCS Integrations: out-of-the-box support for Subversion, Perforce, Git, and CVS with changelists andmerge.

    FTP Sync: update server using FTP or SFTP.

    SQL support: coding assistance, SQL console and Database browser.

    JetBrains PhpStorm is cross-platform. It works on Windows, Mac OS X and Linux and brings the whole range ofprecise developers tools, all tied together to create the convenient development environment.

    What's New

    Getting Help

    Getting Started with PhpStorm

    Basic Concepts

    PhpStorm Usage Guidelines

    Language and Framework-Specific Guidelines

    Reference

    See Also

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Keymap ReferencePhpStorm provides the default platform-specific keymap reference in pdf format.

    To view the keymap reference, choose Help | Default Keymap Reference on the main menu.

    See Also

    Reference:

    Keyboard Shortcuts and Mouse Reference

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Getting Started with PhpStorm

    PhpStorm can be opened simultaneously with WebStorm.

    This chapter briefly outlines what you will need to start using PhpStorm right away.

    Get quickly accustomed with PhpStorm:

    System Requirements and Installation

    Importing PhpStorm Settings on First Launch

    Register PhpStorm

    Tuning PhpStorm

    Guided Tour Around PhpStorm User Interface

    Familiarize Yourself with PhpStorm Editor

    PhpStorm Tool Windows

    Selecting Files and Folders

    Compare Files and Folders

    Familiarize Yourself with IDE Navigation

    Copy and Paste Between PhpStorm and Explorer/Finder

    Configure Your Working Environment

    Create and Run Your First PHP Project

    Create and Run Your First Web Project

    Working with Background Tasks

    Working with PhpStorm Features from Command Line

    Keyboard Shortcuts You Cannot Miss

    PhpStorm Viewing Modes

  • System Requirements and Installation

    PhpStorm can be opened simultaneously with WebStorm.

    In this section:

    Windows

    MacOS

    Linux

    Installing SunJDK

    Windows

    System Requirements Installation

    Microsoft Windows8/7/Vista/2003/XP(incl.64-bit)

    Intel Pentium III/800 MHzor higher (or compatible)

    512 MB RAM minimum, 2GB RAM recommended

    1024x768 minimumscreen resolution

    Oracle (Sun) JDK 1.6 orhigher.

    1. Download PhpStorm athttp://www.jetbrains.com/phpstorm/download/index.html .

    2. Run the PhpStorm-*.exe file that starts the Installation Wizard.

    3. Follow all steps suggested by the wizard. Please pay special attentionto the corresponding installation options.

    Macos

    System Requirements Installation

    Mac OS X 10.5 or higher,including 10.8 (MountainLion)

    JDK 6

    512 MB RAM minimum, 2GB RAM recommended

    1024x768 minimumscreen resolution

    Oracle (Sun) JDK 1.6 orhigher.

    1. Download the PhpStorm-*.dmg Mac OS X Disk Image file athttp://www.jetbrains.com/phpstorm/download/index.html .

    2. Mount the PhpStorm-*.dmg Mac OS X Disk Image file as another diskin your system.

    3. Copy PhpStorm to your Applications folder.

    Linux

    System Requirements Installation

  • Intel Pentium III/800 MHzor higher (or compatible)

    512 MB RAM minimum, 2GB RAM recommended

    1024x768 minimumscreen resolution

    Oracle (Sun) JDK 1.6 orhigher. Open JDK is notsupported.

    GNOME or KDE desktop.

    1. Download the PhpStorm-*.tar.gz file athttp://www.jetbrains.com/phpstorm/download/index.html .

    2. Unpack the PhpStorm-*.tar.gz file using the following command:tar xfz PhpStorm-*.tar.gz

    3. Run PhpStorm.sh from the bin subdirectory.

    4. Install Oracle (Sun) JDK 1.6 or higher if your distribution does notcontain it. Follow the provider's instructions athttp://www.oracle.com/technetwork/java/javase/downloads/index.html.

    Open JDK is not supported.

    To install Oracle (Sun) JDK 1.6, do one of the following:

    Use the Debian repository. In the Command prompt, type the following sequence of commands:

    1. sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"

    2. sudo apt-get update

    3. sudo apt-get install sun-java6-jdk sun-java6-jre sun-java6-plugin

    4. java -version to check that installation is successful.

    Download and install JDK 1.6 from Oracle official site.

    1. Download Oracle (Sun) JDK 1.6 for not RPM-based platforms.

    2. Follow the installation instructions .

    3. Specify the directory where JDK is installed through the JAVA_HOME variable.

    See Also

    External Links:

    http://wiki.jetbrains.net/intellij/Installing_and_running_PHPStorm_on_Ubuntu

    http://wiki.jetbrains.net/intellij/Configuring_PHP_development_environment_on_Ubuntu

    http://theaccidentalcoder.com/content/swapping-openjdk-sun-jdk-ubuntu

    http://www.jetbrains.com

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Importing PhpStorm Settings on First LaunchWhile working with PhpStorm, you've definitely customized the IDE settings (for example, editor behavior, orkeyboard shortcuts) to fit your needs. Having installed and launched a newer version of PhpStorm (when theconfig directory doesn't yet exist for the new version), you might want to re-use the settings of the previousversions.

    For this purpose, PhpStorm automatically shows a dialog box with the following options:

    I want to import settings from the previous version: If this option is selected, PhpStorm automaticallydetects the home directory of the previous version, and imports settings from this location.

    I want to import settings from custom location: If this option is selected, you can specify the desireddirectory where the settings are stored.

    Type the path manually, or click the browse button to select settings from the previous version using the filechooser dialog.

    I don't have a previous version of PhpStorm, or I don't want to import settings: If this option is selected,then all the previous settings (if any) will be ignored.

    Click the radio-button of the desired option to re-use or ignore the legacy settings.

    If automatic import fails, consider importing and exporting settings manually, using the File | ExportSettings and File | Import Settings commands on the main menu. Refer to section Exporting andImporting Settings.

    See Also

    Concepts:

    Project and IDE Settings

    Procedures:

    Exporting and Importing Settings

    External Links:

    Running IntelliJ IDEA Ultimate for the First Time

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Tuning PhpStormIn this section:

    Increasing productivity

    Example. Increasing heap size

    Managing case of unicode literals

    Increasing productivity

    To increase productivity of PhpStorm, you can change settings that reside in the following locations (dependingon your operating system):

    On Windows systems:

    /bin/PhpStorm.exe.vmoptions

    or

    /bin/PhpStorm64.exe.vmoptions

    On *NIX systems:

    /bin/PhpStorm.vmoptions

    or

    /bin/PhpStorm64.vmoptions

    On Mac OS:

    The file /Applications/PhpStorm.app/bin/idea.vmoptions should be copied to

    ~/Library/Preferences/WebIdeXX/idea.vmoptions

    Example. increasing heap size

    For example, to increase PhpStorm heap size, you should copy the original .vmoptions file from/Applications/PhpStorm.app/bin/idea.vmoptions to~/Library/Preferences/WebIdeXX/idea.vmoptions, then modify the -Xmx setting.

    For the older versions, the settings are stored in:

    /Applications/PhpStorm.app/Contents/Info.plist

    Managing case of unicode literals

    PhpStorm allows defining whether non-ascii characters should use literals like '\u00AB' or '\00ab'.

    This behavior is controlled by the system property idea.native2ascii.lowercase. By default, upper casecharacters are used.

    If it is desirable to use lower case characters, do the following (depending on your platform)

    On Windows and *NIX: add the line

    idea.native2ascii.lowercase=true

    to the bin/PhpStorm.properties file, located under the product installation.

  • On Mac OS:

    Copy the file /Applications/PhpStorm.app/bin/PhpStorm.properties to~/Library/Preferences/WebIdeXX/, open it for editing, and add the line

    idea.native2ascii.lowercase=true

    It is essential to create a copy, since the settings are replaced rather than added.

    For the older versions of PhpStorm, open for editing the file/Applications/PhpStorm.app/Contents/Info.plist, and add the following code:

    idea.native2ascii.lowercase true

    to the section Properties ...

    See Also

    Reference:

    Project and IDE Settings

    External Links:

    Product files locations (caches, plugins, logs) on different operating systems

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Guided Tour Around PhpStorm User InterfaceThis chapter gives you insight into how PhpStorm user interface is organized to help you find your way throughyour working environment.

    This chapter outlines the default (out-of-the-box) IDE interface layout. Note that plugins and other add-onsyou are installing may change the way your IDE looks and behaves, for example there can be extracommand buttons or menu items appearing in uncommon locations.

    When you first run PhpStorm, or have no open project, PhpStorm displays the Welcome screen, which enablesquick access to the major entry points. When a project is opened, PhpStorm displays the main window. Thiswindow is made up of six logical areas, which are shown on the picture below, marked with red number labels.

    1. Menus and toolbars - the main menu and toolbars let you carry out various commands.

    2. Navigation bar that helps navigate through the project and open files for editing.

    3. The status bar - indicates the status of your project, the entire IDE, and shows various warning andinformation messages.

    4. The editor - here you create and modify the code.

    5. PhpStorm tool windows - secondary windows that provide access to various specific tasks (projectmanagement, source code search and navigation, running and debugging, integration with version controlsystems, etc.).

    See Also

    Concepts:

    Basic Concepts

    Procedures:

    PhpStorm Usage Guidelines

    Reference:

    Reference

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Welcome ScreenPhpStorm displays the Welcome screen, when no project is opened. From this screen, you can quickly accessthe major starting points of PhpStorm. Welcome screen appears, when you close the current project in the onlyinstance of PhpStorm. If you are working with multiple projects, closing a project results in closing thePhpStorm window, in which it was running, except for the last one.

    Welcome screen is divided into the following sections: Quick Start, and Recent Projects .

    Quick StartUse the links of this section to create a new project, open project, create a project from existing sourcesor check out a project from version control.

    Also, use the Configure link to configure your working environment and default project, andDocumentation link to open help topics, tips of the day, and default keymap document.

    Recent ProjectsUse the links in this section to reopen one of the recent projects.

    See Also

    Concepts:

    Project

    Procedures:

    Creating and Managing Projects

    Version Control with PhpStorm

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Menus and ToolbarsPhpStorm menus and toolbars let you carry out various commands. The main menu and toolbar containcommands that affect the entire project or large portions of it. Additionally, context-sensitive pop-up menus letyou perform the commands, which are specific to a part of a project, like source file, class, etc. Almost each ofthe commands has an associated keyboard shortcut to enable quicker access to it.

    1. Main menuThe main menu contains commands for opening, creating projects, refactoring the code, running anddebugging applications, keeping files under version control and more.

    2. Main toolbarThe main toolbar contains buttons that duplicate the essential commands for quicker access. You canhide the main toolbar, using the checked command on the toolbar context menu.

    3. Pop-up menusThese menus contain commands specific for a certain project item.

    4. Context menusThese menus contain commands applicable to the current context.

    Show or hide the main elements of the PhpStorm UI using the View menu.

    Descriptions of the actions from all the menus and toolbar buttons are displayed in the left side of theStatus bar.

    If you know which action you want to perform, but do not know where to find the appropriatecommand, just press Ctrl+Shift+A and select the desired action from the suggestion list.

    See Also

    Procedures:

    Configuring Menus and Toolbars

    Navigating to Action

    Reference:

    Keyboard Shortcuts and Mouse Reference

    Menus and Toolbars

    Tool Windows Reference

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Navigation BarNavigation Bar is a quick alternative to the Project view. Use this tool to navigate through the project and openfiles for editing.

    To show the Navigation Bar, do one of the following

    On the View menu, select the Navigation Bar option.

    Press Alt+Home.

    To hide the Navigation Bar, do one of the following

    On the View menu, clear the Navigation Bar option.

    Click the close icon in the upper-right corner of the Navigation Bar.

    When the main toolbar is hidden, the Navigation Bar shows the run/debug configuration selector, run and debug buttons.

    When the Navigation bar is hidden, press Alt+Home to open it floating, and Escape to hide it.

    See Also

    Procedures:

    Navigating with Navigation Bar

    Opening and Reopening Files in the Editor

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Status BarPhpStorm status bar indicates the current IDE state and lets you carry out certain environment maintenancetasks.

    Icon Description

    Click to toggle showing or hiding tool window bars. Also double press and holdAlt to show hidden tool window bars. Refer to the procedure description.

    Shows description of a command, currently selected on the main menu, contextmenu, or a toolbar.

    Click this icon to invoke the Background Tasks manager.

    The first two numbers denote the current caret position in the editor(line andcolumn).

    If a selection is made in the editor, PhpStorm shows the length of the currentselection after slash.

    Lock icon indicates the read-only or writable attribute of the current file in theeditor. Click the icon to toggle file attribute.

    Use also File | Make File Writable/Read-only command on the mainmenu.

    Indicates whether the new characters in the editor overwrite the existing ones.In the Overwrite mode, the form of the cursor changes to a rectangle. Press theInsert key to toggle the Insert and Overwrite modes.

    View and change line endings of the current file in the editor.

    View and change encoding of the current file in the editor.

    Hovering your mouse pointer over the icon shows the current code inspectionprofile at the tooltip.

    Clicking the Hector icon results in showing a dialog box with the followingfunctions:

    Highlighting level. Use the slider to change highlighting level for the currentfile, or configure inspection profile.

    Depending on the highlighting level selected by the slider, Hector keeps aneye on the code (Inspection level), turns half face (Syntax), or avertshis face from the code (None).

  • Power Save Mode. Select this check box to minimize power consumption ofyour computer on account of eliminating the background operations.

    When Power Save Mode is on, PhpStorm reduces its functionality to the oneof a text editor, by not executing expensive background activities that drainlaptop battery. These activities include error highlighting and on-the-flyinspections, autopopup code completion .

    Hector fades .

    You can also toggle Power Save Mode on the main menu (File | PowerSave Mode).

    Click this icon to navigate to the pending source control changelists in theIncoming tab of the Changes tool window.

    Shows the current heap level and memory usage. Visibility of this section in theStatus bar is defined by the Show memory indicator check box in theAppearance page of the Settings dialog.

    Click the memory indicator to run the garbage collector.

    More icons appear in the Status bar as you download and install plugins.

    See Also

    Concepts:

    Code Inspection

    Reference:

    IDE Settings

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Familiarize Yourself with PhpStorm EditorPhpStorm editor is a powerful tool for creating and modifying source code. As any other IDE editor, it supportsbasic features like bookmarks, breakpoints, syntax highlighting, code completion, zooming, folding code blocks,etc. There are, however, plenty of advanced features like macros, highlighted TODO items, code analysis,intention actions, intelligent and fast navigation, and a lot more.

    To configure your editing environment, use the Editor settings page and its child pages. There is also a QuickSwitch Scheme command that lets you change color schemes, themes, keymaps, etc. with a couple ofkeystrokes.

    The editor is tab-based. All operations with the editor tabs are available from the context menu of a tab, orfrom Window | Editor tabs node of the main menu.

    When you open a file for editing, it opens in its own tab. The editor you are currently working in, is the activeeditor. You can change behavior of the active editor using the commands under View | Active Editor node ofthe main menu.

    You always return the focus to the active editor from any tool window by pressing the Escape key.

    1. Editor areaUse this area to type and edit your source code. The editor suggests numerous coding assistancefacilities. Refer to the sections under this node, and to Basic Editing Procedures and Advanced EditingProcedures for details.

    2. Gutter areaThe left gutter provides additional information about your code and displays the various icons thatidentify the code structure, bookmarks, breakpoints, scope indicators, change markers and the codefolding lines that let you hide arbitrary code blocks.

    3. Smart completion pop-upThis is one of the key editing assistance features that suggests method names, functions, tags and otherkeywords you are typing.

    4. Document tabsEnable quick navigation across the multiple documents you are working on. Clicking a tab brings itscontents to front and makes it available for editing in the active editor.

    To move between the tabs, use the keyboard shortcuts Alt+Right or Alt+Left.

    Clicking a tab while the Ctrl key is pressed, allows you to navigate to any part of the file path, throughopening it in an external browser.

    Context menu of a tab provides all commands applicable to a file opened in the editor, for example:

    Close one or more tabs.

    Pin active tab.

    Split and unsplit tabs.

    Manage groups of tabs.

    Navigate between tabs.

    Add to Favorites.

    Move to changelist.

    Run, or debug in the active editor.

  • Perform local history and version control commands.

    Perform commands of your own tools.

    By default, the tabs appear on top of the editor, but you can change their location as described in thesection Changing Placement of the Editor Tabs .

    5. Validation side bar / marker barThis is the bar to the right from the editing area, showing the green, red or yellow box on its topdepending on whether your code is okay, or contains errors or warnings. This bar also displays activered, yellow, white, green and blue navigation stripes that let you jump exactly to the erroneous code,changed lines, search results, or TODO items.

    In this section:

    Opening and Reopening Files in the Editor

    Closing Files in the Editor

    Saving and Reverting Changes

    Adding Editors to Favorites

    Zooming in the Editor

    Viewing Current Caret Location

    Managing Editor Tabs

    Basic Editing Procedures

    Advanced Editing Procedures

    Using TODO

    See Also

    Concepts:

    Supported Languages

    Procedures:

    Finding and Replacing Text in File

    IDE Settings

    Running

    Debugging

    Reference:

    Tool Windows Reference

    Navigation in Source Code

    General

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Opening and Reopening Files in the EditorIn this section:

    Opning a file for editing

    Opening a file which is external to your project

    Opening a directory

    Reopening a recent file

    Important note

    To open a file for editing

    1. Do one of the following:

    Double-click the desired file in one of the Tool Windows.

    Select the desired file in one of the Tool Windows and press F4.

    Select the desired file in the one of the Tool Windows and choose Jump to Source on the contextmenu.

    Use the Navigate command for a Class, File, or Symbol.

    Click the desired directory in the Navigation bar, and select file from the drop-down list:

    2. If the file type is registered, the file opens silently in PhpStorm's editor.

    If the file type is registered under the category Files opened in associated applications, it will be opened inits associated application, rather than in the PhpStorm editor. By default, PhpStorm suggests a number ofsuch file types, for example .doc, .chm, or .pdf.

    If the file type is unknown, PhpStorm suggests you to choose whether you want to register a new file type,or open such file in its associated application. Specify your choice in the Register New File Type Associationdialog box:

    You can register the required file types on the File Types page of the Settings dialog box.

    To open an external file, do one of the following

    1. Choose File | Open on the main menu and select the desired file in the dialog box that opens.

    2. Drag the required file from the Explorer (on Windows), File Browser (Linux), or Finder (on Mac) and drop itto the editor. The file will be opened for editing in a new tab.

  • To open a directory

    On the main menu, choose File | Open Directory, and select the desired directory in the dialog thatopens.

    After that, you can open any file from the directory either in the editor in the associated application. If thefile type is unknown, you can also register it in the Register New File Type Association dialog box.

    To reopen a recent file, do one of the following:

    To open a recently opened file, choose View | Recent Files on the main menu or press Ctrl+E. Thenselect the desired file from the Recent Files pop-up window, that opens.

    To open a recently updated file, on the main menu, choose View | Recently Changed Files or pressCtrl+Shift+E. Then select the desired file from the Recently Edited Files pop-up window, that opens.

    Use Recent files limit text box in the Editor settings page to define the maximum number of recentfiles.

    Important note

    The maximum size of files parsed by PhpStorm is controlled by the idea.max.intellisense.filesizesetting in idea.properties file, located in the bin directory of PhpStorm installation. However, the largerfile is, the slower its editor works and higher overall system memory requirements are.

    See Also

    Procedures:

    Navigating to Recent File

    Closing Files in the Editor

    Opening Language Injections in the Editor

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Closing Files in the EditorPhpStorm suggests several ways to close editor tabs.

    To close a file in the editor, do one of the following

    On the main menu point to Window | Editor Tabs, choose one of the appropriate closing commands.

    CloseCloses the file in the active tab.

    Close AllCloses all editor tabs.

    Close OthersCloses all tabs except the current one. The alternative way to close all other tabs lays with clickingthe button, while holding the Alt key pressed:

    Close UnmodifiedCloses all files that were not changed.

    Close All But PinnedCloses all files that were not pinned. This command appears, if there are pinned editor tabs.

    Right-click any editor tab, and choose same commands on the context menu.

    Point with your mouse cursor to a tab and click the middle mouse button.

    Point with your mouse cursor to a tab and click .

    Press Ctrl+F4.

    When you close modified files, PhpStorm preserves all changes in the current editing session. Afterreopening such files, the results of editing are restored.

    See Also

    Procedures:

    Opening and Reopening Files in the Editor

    Saving and Reverting Changes

    Closing an Editor for a Language Injection

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Saving and Reverting ChangesYou can save the results of editing yourself, and also configure PhpStorm to enable automatic saving ofchanges. This section describes how to:

    Save changes when done with editing.

    Alert you about unsaved changes by marking a modified file in the editor tab with an asterisk next to itsname.

    Enable auto-saving changes on the regular basis.

    Enable auto-saving changes on switching to the other applications.

    Enable preserving temporary files.

    Revert changes.

    To save results of editing, do one of the following

    On the main menu, choose File | Save All.

    Press Ctrl+S.

    To alert you about unsaved changes

    1. Open Settings dialog box, expand the Editor node, and click Editor Tabs.

    2. In the Editor Tabs page, select the Mark modified tab with asterisk check box.

    To enable auto-saving on the regular basis

    1. In the IDE Settings section of the Settings dialog box, click General.

    2. Select the Save files automatically, if the application is idle check box and specify the number ofseconds of idleness required to activate saving.

    To enable saving changes when switching to other applications

    1. In the IDE Settings section of the Settings dialog box, click General.

    2. Select the Save files on frame de activation check box.

    If the check box is cleared, a conflict may occur between the PhpStorm's version in the memory cache andthe version produced in the file system. PhpStorm prompts you to resolve the conflict.

    To enable preserving temporary files while saving changes

    1. In the IDE Settings section of the Settings dialog box, click General.

    2. Select the Use "safe write" check box.

    If this check box is selected, modified file will be first saved as a temporary file. If the save operation iscompleted successfully, the temporary file will renamed, and the original file will be deleted.

    To revert change, do one of the followings

    On the main menu, choose File | Synchronize.

    Press Ctrl+Alt+Y.

    Refer to the Local History for more powerful way of reverting changes.

  • See Also

    Procedures:

    Using Local History

    Reference:

    Settings / Preferences Dialog

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Adding Editors to FavoritesYou can group most needed items into Favorite lists and get quick access to them through the Favorites toolwindow.

    To add one or more items to favorites

    1. Do one of the following:

    Open the desired files in the Editor.

    Select one or more items in the Project tool window.

    2. Right-click the editor tab or the selection in the Project tool window, and choose Add to Favorites on thecontext menu.

    3. On the submenu, specify the Favorites list to add the selected items to. Do one of the following:

    To add the items to an existing list, select the desired list in the submenu.

    To create a new list, choose Add to New Favorites List. In the Add New Favorites List dialog boxthat opens enter the desired group name or accept default settings.

    See Also

    Reference:

    Favorites Tool Window

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Zooming in the EditorPhpStorm makes it possible to change font size (zoom) in the active editor, and reset font size to the defaultvalue. These operations apply to the active editor only. In the other editor tabs, font size is not affected.

    In this section:

    Enabling zooming

    Changing font size with the mouse wheel

    Restoring default font size

    To enable changing font size in the editor

    1. Open the IDE settings dialog.

    2. On the Editor page, make sure that the setting Change font size (Zoom) with Ctrl+MouseWheel isenabled.

    To change font size using the mouse wheel

    1. Place the caret in the editor.

    2. While keeping the Ctrl key pressed, rotate the mouse wheel. As you rotate the mouse wheel forward, fontsize grows larger; as you rotate the mouse wheel backwards, font size decreases.

    The MacOS users can use trackpad "Pinch-to-Zoom" gesture to change size of the font and the wholeediting area.

    To reset font size

    1. Press Ctrl+Shift+A.

    2. In the popup frame, type Reset font size, and click Enter.The default font size is restored.

    There is no default keyboard shortcut associated with Reset font size action. However, you can create yourown shortcut as described in the section Configuring Keyboard Shortcuts.

    See Also

    Reference:

    Editor

    Getting Started:

    Familiarize Yourself with PhpStorm Editor

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Managing Editor TabsEvery time you open a file for editing, a dedicated tab is added to the editor window, next to the active editortab. By default, when the number of tabs reaches its limit, the editor closes the tabs according to the tab closingpolicy.

    All commands, related to managing editor tabs, are available from:

    Window | Editor Tabs menu.

    Context menu of a tab.

    In this section:

    Configuring Behavior of the Editor Tabs

    Navigating Between Editor Tabs

    Pinning and Unpinning Tabs

    Splitting and Unsplitting Editor Window

    Detaching Editor Tabs

    Editing Multiple Files Using Groups of Tabs

    Changing Placement of the Editor Tabs

    See Also

    Procedures:

    Accessing the IDE Settings

    Pinning and Unpinning Tabs

    Web Resources:

  • Discussion Forum

    Issue Tracker

  • Configuring Behavior of the Editor TabsYou can change the way PhpStorm handles the editor tabs in the Editor tabs page of the Editor settings.

    To change the maximum allowed number of tabs

    1. Open the Editor settings. To do that, click on the main toolbar, then click the Editor node in the Settingsdialog box, that opens.

    2. In the Editor Tabs page of the Editor settings, type the desired maximum allowed number of the editor tabsto be opened at a time in the Tab limit field.

    If the tab limit equals to 1, the tabs will be disabled. If you want the editor to never close the tabs, typesome unreachable number.

    To disable editor tabs

    In the Editor Tabs page of the Editor settings, select None from the Tab placement drop-down list.

    With the disabled tabs, use the View | Recent files (Ctrl+E) command to quickly switch betweenfiles.

    See Also

    Reference:

    Editor. Editor Tabs

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Navigating Between Editor TabsIn this section:

    Navigating between editor tabs

    Navigating though the previously visited tabs

    Viewing all opened editor tabs and choosing the active editor

    To navigate from the current tab to the next or previous tab, do one of the following

    Right-click the current editor tab and choose Select Next/Previous Tab on the context menu.

    Press Alt+Right or Alt+Left. So doing, the focus moves to the editor tab located next to the right or tothe left from the active editor tab.

    Press Ctrl+Tab or Ctrl+Shift+Tab to use the Switcher.

    This approach allows jumping from one tab to another as your editing session requires. While you movebetween the editor tabs, PhpStorm remembers the caret position within each opened file.

    To go back and forth through the history of visited tabs, do one of the following

    On the main toolbar, click or .

    On the main menu, choose Navigate | Back / Forward.

    Press Ctrl+Alt+Left or Button4 Click or Ctrl+Alt+Right or Button5 Click.

    This approach enables you to move back and forth through the history of your navigation, same way as it isdone in a Web browser. As you move from file to file during your editing session, PhpStorm keeps track of thevisited locations and enables you to go back, using the Navigate | Back / Forward commands.

    On a Mac OS X computer, you can also use the three-finger right-to-left and left-to-right swipe gestures.

    To view all editor tabs and select the active editor

    If all opened tabs are shown in a single row, some of the tabs may become invisible. PhpStorm helps displaythe list of the opened editor tabs that did not fit in the editor window and have become invisible whereupon youcan choose the tab to activate.

    1. Do one of the following:

    On the main menu, choose Window | Editor Tabs | Show All Tabs

    Click

    The list of all the tabs that are opened but invisible appears. So doing the names of the tabs, which arecurrently visible, are displayed on the light background; the names of the tabs outside of the main windoware shown on the darker background.

    2. Click the name of the desired editor tab:

    The selected editor tab becomes active and gets the focus.

    The command Show All Tabs and the icon are only available when:

  • The Show tabs in single row check box is selected in the Editor tabs page of the Editor settings.

    Some of the opened tabs are not visible because they do not fit in the editor window.

    See Also

    Procedures:

    Navigating to Recent File

    Reference:

    Editor. Editor Tabs

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Pinning and Unpinning TabsWhen you pin a tab, you make sure that such tab will not be automatically closed, when the editor starts closingthe editor tabs automatically. Besides, when you close the editor tabs, you have an option to preserve pinnedtabs opened and close only the unpinned tabs.

    When a tab is pinned, there is a special marker on it.

    The pinned status of a tab is helpful when you open a file for reference, rather than for editing.

    To pin an editor tab

    1. Switch to the desired editor tab.

    2. Right-click the editor tab, and choose Pin Tab on the context menu:

    To unpin a tab

    1. Switch to the desired editor tab.

    2. Right-click the editor tab, and choose Unpin Tab on the context menu.

    See Also

    Procedures:

    Closing Files in the Editor

    Reference:

    Editor

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Splitting and Unsplitting Editor WindowSplitting the editor window divides it into independent panes. You can split the editor window into as manypanes as required, each one containing multiple tabs.

    Each pane can be allocated vertically or horizontally. Thus, splitting helps create different editor layouts,organize tabs into groups, and edit multiple files simultaneously. For example, you can scroll through a part of afile, having at the same time the possibility to view the lines in its other part.

    To split an editor tab

    1. Switch to the desired tab.

    2. Right-click the tab header and choose Split Vertically or Split Horizontally on the context menu.

    To change splitter orientation

    1. Switch to the desired tab.

    2. Right-click the tab header and choose Change Splitter Orientation on the context menu.

    To remove splitter

    1. Switch to the desired tab.

    2. Right-click the tab header and choose one of the following commands on the context menu:

    To remove splitting in the active tab, choose Unsplit.

    To remove splitting in all the open editor tabs, choose Unsplit All.

    See Also

    Procedures:

    Editing Multiple Files Using Groups of Tabs

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Detaching Editor TabsPhpStorm makes it possible to detach editor tabs, and move them to separate frames.

    To detach an editor tab, drag it outside of the main window. A preview thumbnail appears:

    The contents of the editor tab is opened in a separate frame.

    To attach an editor tab, drag it from its frame and drop to the main PhpStorm frame until tab nameappears:

    The detached editor tabs can be split or unsplit.

    You can move editor tabs between split panes.

    See Also

    External Links:

    Demo

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Editing Multiple Files Using Groups of TabsYou can arrange tabs into groups to facilitate working with multiple files at a time. PhpStorm allows you to havean unlimited number of tab groups, thus enabling you to view several files or several places within the samefile.

    To create a new group of tabs

    Just split the desired editor tab.

    To move a tab from one group to another

    1. Switch to the desired tab.

    2. Right-click the desired editor tab and choose Move Tab to Opposite Tab Group on the context menu.

    See Also

    Procedures:

    Splitting and Unsplitting Editor Window

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Changing Placement of the Editor TabsBy default, the tabs appear on top of the editor, but you can change their location as required, and have thetabs at the bottom, left, or right sides of the editor. Note that the tab placement is a global setting that appliesto all projects.

    To change location of the editor tabs, do one of the following

    In the Editor Tabs page, select editor tabs position from the Placement drop-down list.

    Right-click an editor tab, point to the menu item Tabs Placement, and then select the desired placementin the sub-menu.

    To sort editor tabs alphabetically

    The alphabetical sorting of the editor tabs is available when the editor tabs are located to the left or to theright from the editor pane.

    In case of the top or bottom placement of the editor tabs, this command is disabled. However, alphabeticalorder for top and bottom placement becomes available, when Show tabs in single row check box isselected in the Editor Tabs page of the Settings dialog.

    1. Right-click an editor tab.

    2. Select the check command Alphabetical Mode.

    If this check command is selected, the tabs are presented in alphabetical order. Otherwise, the editor tabsappear in the order of opening the corresponding files.

  • Basic Editing ProceduresThis section describes how to perform the most common editing tasks:

    Adding, Deleting and Moving Lines

    Cutting, Copying and Pasting

    Selecting Text in the Editor

    Undoing and Redoing Changes

    Using Drag-and-Drop in the Editor

    Commenting and Uncommenting Blocks of Code

    See Also

    Procedures:

    Configuring IDE Settings

    Reference:

    Editor

    Getting Started:

    Familiarize Yourself with PhpStorm Editor

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Adding, Deleting and Moving LinesIn this section:

    Adding lines

    Duplicating lines

    Deleting lines

    Moving lines

    Moving statements

    To add a line

    Press Shift+Enter to add a new line after the one where the caret is currently located and move the caretto the beginning of this new line.

    For instance, you have typed some text:

    Press Shift+Enter to start the next line immediately:

    To add a line before the current one, press Ctrl+Alt+Enter.

    To duplicate a line or fragment

    1. Place the caret at the line to be duplicated, or select the desired fragment of text.

    2. Press Ctrl+D.

    To remove a line

    Press Ctrl+Y to delete the line at caret.

  • To move a line

    1. Place the caret at the line to be moved.

    2. Do one of the following:

    On the main menu, choose Code | Move Line Up or Code | Move Line Down.

    Press Shift+Alt+Up or Shift+Alt+Down.

    PhpStorm moves the selected line one line up or down, performing the syntax check. For example:

    After moving line at caret:

    To move a statement up or down

    1. Select a statement to be moved, or just place the caret at the first or last lines of a multi-line statement.Note that if moving a statement is not allowed in the current context, the commands will be disabled.

    2. Do one of the following:

    On the main menu, choose Code | Move Statement Up/Move Statement Down.

    Press Ctrl+Shift+Up or Ctrl+Shift+Down.

    If you apply the same commands to a line at caret, or a to a selection, it will be moved one line up ordown.

    PhpStorm moves the selected statement above the previous one, or directly underneath the next one,performing the syntax check. For example, place the caret at the method declaration:

    After moving the statement:

  • Make sure that keyboard shortcuts are not in conflict. You can do that in the Keymap page of the IDESettings.

    See Also

    Procedures:

    Selecting Text in the Editor

    Configuring Keyboard Shortcuts

    Reference:

    Keyboard Shortcuts and Mouse Reference

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Cutting, Copying and PastingPhpStorm provides a number of handy Clipboard operations. You can copy, cut, and paste selected text, a pathto a file, or a reference to a symbol or a line of code.

    Because PhpStorm uses the system Clipboard, you can copy and paste between applications. So doing, whenpasting Clipboard entries, PhpStorm removes any formatting from the text and any special symbols from theString values.

    The Paste command smartly understands what is being inserted. If you paste a reference to a symbol, it isanalyzed for possible imports, references, etc. So doing, PhpStorm provides the necessary brackets and placesthe caret at the appropriate insertion point. The Paste Simple command helps paste any Clipboard entry as aplain text, without any analysis.

    PhpStorm enables Clipboard stacking, which means that you can store multiple Clipboard entries and accessthem with a single shortcut. The number of entries that can be kept in the Clipboard stack is customizable onthe Editor page of the IDE Settings.

    To copy selected text, do one of the following

    On the main menu, choose Edit | Copy.

    Press Ctrl+C or Ctrl+Insert.

    Click the Copy button on the toolbar.

    The Ctrl+D keyboard shortcut clones a line at the caret or a selected arbitrary fragment of text.

    To copy path to a file, do one of the following

    Open the desired file in the editor, then choose Edit | Copy Path on the main menu or pressCtrl+Shift+C.

    Select the desired file in the Project tool window and choose Copy Path on the context menu of theselection.

    To copy reference to a line or symbol

    1. Open the desired file in the editor.

    2. Place the caret at a certain line of code.

    3. Do one of the following:

    On the main menu, choose Edit | Copy Reference

    On the context menu of the line at caret, choose Copy Reference

    Press Ctrl+Shift+Alt+C.

    PhpStorm creates a string in the format that depends on the symbol at caret.

    \MyNamespace\Catcher for a PHP class

    \MyNamespace\Catcher::$name for a PHP variable

    \MyNamespace\Catcher::set_experience for a PHP method

  • To cut the selected text

    1. Select the desired fragment in the editor.

    2. Do one of the following:

    On the main menu, choose Edit | Cut.

    Press Ctrl+X or Shift+Delete.

    Click the Cut button on the toolbar.

    To paste the last entry from the clipboard

    1. Place the caret in the location where you want to paste content.

    2. Do one of the following:

    On the main menu, choose Edit | Paste.

    Press Ctrl+V or Shift+Insert.

    Click the Paste button on the toolbar.

    If you perform paste in a language file, the further behavior depends on the settings in the Auto Importpage of the Editor options. If the Ask option has been selected, select the necessary imports from thelist of missing imports. In all other cases, the last clipboard entry is pasted silently.

    To paste the last entry from the clipboard as plain text, do one of the following

    On the main menu, choose Edit | Paste Simple.

    Press Ctrl+Shift+Alt+V.

    To paste a specific entry from the clipboard

    1. On the main menu, choose Edit | Paste from History or press Ctrl+Shift+V or Ctrl+Shift+Insert.

    2. In the Choose Content to Paste dialog box select the desired entry from the list of recent Clipboardentries, and click OK.

    The depth of the Clipboard stack is configured in the Limits section on the Editor page of the Settingsdialog box. When the specified number is exceeded, the oldest entry is removed from the list.

    See Also

    Procedures:

    Configuring IDE Settings

    Reference:

    Editor

    Keyboard Shortcuts and Mouse Reference

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Selecting Text in the EditorThe basic way to select a piece of text is to extend the selection with the mouse cursor. PhpStorm, as akeyboard-centric IDE, suggests to use navigation keys to make selections. You can opt to select pieces of text bylines, or select rectangular fragments in the column mode, extend and shrink the selection, and use stickyselection.

    In this section:

    Selecting all text in the active editor tab

    Selecting with navigation keys

    Extending selection

    Toggling between selection modes

    Using the column selection mode

    Using smart selection

    Toggling sticky selection

    To select the entire text in the current editor tab, do one of the following

    On the main menu, choose Edit | Select All.

    Press Ctrl+A.

    To select text with navigation keys, use one of the following shortcuts

    Ctrl+Shift+Left, Ctrl+Shift+Right to select text from the caret position to the beginning/end of thecurrent word.

    Ctrl+Shift+Page Up, Ctrl+Shift+Page Down to select text from the caret position to the top/bottom ofthe screen.

    To extend selection from the word at the caret to the piece of code the caret is contained in, usethe following shortcuts

    Press Ctrl+W to select the word where the caret is currently located.

    Press Ctrl+W successively to extend selection to the next containing node (for example, an expression, apaired tag, an entire conditional block, a method body, a class, a group of vararg arguments, etc.)

    While extending selection, keep in mind the following:

    Pressing Ctrl+W successively in plain text or comments extends the selection first to the currentsentence, then to the current paragraph.

    Press Ctrl+Shift+W to shrink selection in the reverse order (from the outermost container to the wordwhere the caret currently resides).

    The selection extends or shrinks according to capitalization, if the Use "CamelHumps" words isenabled on the Editor. Smart Keys settings page.

    If you want to make selection according to capitalization, using double-click, make sure that the optionHonor CamelHumps words... is selected on the Editor settings page.

  • To toggle between the line and the column selection modes, do one of the following

    On the main menu, choose Edit | Column Selection Mode.

    On the context menu of the editor, choose Column Selection Mode.

    Press Shift+Alt+Insert.

    Keeping the middle mouse button pressed, drag the mouse.

    To make selection in the column selection mode

    Keeping the Alt key pressed, drag your mouse pointer to select the desired area.

    Keeping the middle mouse button pressed, drag your mouse pointer to select the desired area.

    To use smart expression selection

    When you perform various code refactorings that involve selecting an expression , PhpStorm can help youselect the expression of interest. This feature is known as smart expression selection.

    The procedure for the Introduce Variable refactoring is just an example. The smart expression selectionfeature, in fact, is available in all the refactorings that start with selecting an expression.

    1. Place the cursor before or within the expression.

    2. Choose Refactor | Extract Variable from the main or the context menu, or press Ctrl+Alt+V.

    3. In the Expressions pop-up menu, select the expression. To do that, click the required expression.Alternatively, use the Up and Down arrow keys to navigate to the expression of interest, and then pressEnter to select it.

  • To toggle sticky selection, do one of the following

    Press Ctrl+Shift+A, in the pop-up frame type sticky, and choose Toggle Sticky Selection from thesuggestion list:

    In the Emacs keymap, use keyboard shortcut Ctrl+Space.

    When sticky selection is on, you can turn it off by invoking copy or cut, or by toggling it again.

    See Also

    Procedures:

    Configuring IDE Settings

    Extract Variable

    Reference:

    Editor

    Keyboard Shortcuts and Mouse Reference

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Undoing and Redoing ChangesThe Undo command discards the last changes to the file in the editor. The Redo command discards the resultsof the last Undo command.

    You can undo or redo your changes as many times as required. However, when you exit PhpStorm, the undohistory is lost.

    PhpStorm smartly defines the logical steps that can be undone and redone. The following events signal aboutthe end of a logical step:

    Pressing Enter.

    Repositioning the mouse cursor.

    Using navigation keyboard shortcuts.

    Cutting or pasting.

    Pressing Tab.

    To undo an action, do one of the following

    On the main menu, choose Edit | Undo.

    Press Ctrl+Z or Alt+Backspace.

    To redo an action, do one of the following

    On the main menu, choose Edit | Redo.

    Press Ctrl+Shift+Z or Shift+Alt+Backspace.

    PhpStorm expands the undo and redo mechanism to complex operations, such as reformatting orrefactoring source code, creating or deleting files. When you undo or redo a complex operation, PhpStormrequests on your confirmation.

    See Also

    Reference:

    Keyboard Shortcuts and Mouse Reference

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Using Drag-and-Drop in the EditorPhpStorm allows copying and moving code fragments within the active editor tab, by means of drag-and-drop.

    To move or copy code fragment

    1. Make sure that using drag-and-drop is enabled in the Editor page of the IDE Settings.

    2. Select the desired fragment in the editor.

    3. Move or copy selection:

    Move: Drag the selected fragment to the target location.

    Copy: Keeping the Ctrl key pressed, drag selection to the target location.

    See Also

    Procedures:

    Editor

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Commenting and Uncommenting Blocks of CodeYou can comment or uncomment the current line or selected block of source code.

    Commenting feature extends to all supported file types. For the custom file types, you can define line and blockcomments characters, as described in the section Creating and Registering File Types.

    To comment or uncomment the current line of code, do one of the following

    On the main menu, choose Code | Comment with Line Comment.

    Press Ctrl+Slash or Ctrl+NumPad /.

    To add or remove a block comment, do one of the following

    On the main menu, choose Code | Comment with Block Comment.

    Press Ctrl+Shift+Slash or Ctrl+Shift+NumPad /.

    See Also

    Procedures:

    Creating PHP Documentation Comments

    Creating JSDoc Comments

    Creating and Registering File Types

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Advanced Editing ProceduresThis part describes more sophisticated editing techniques provided by PhpStorm:

    Code Folding

    Improving Visibility of the Source Code

    Spellchecking

    Using Macros in the Editor

    See Also

    Reference:

    Advanced Editing

    External Links:

    Configuring IDE Settings

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Code FoldingCode folding lets you collapse (fold) code blocks, reducing them to a single visible line. In this way, you can hidethe details that, at the moment, seem unimportant. If and when necessary, the folded code blocks can beexpanded (unfolded).

    Folded code blocks are shown as shaded ellipses.

    You can fold (collapse) and unfold (expand) the code blocks by using:

    Code folding toggles ( , or ). These toggles are shown in the editor to the left of the correspondingblocks. If a block is not folded, indicates the beginning of the block while is located at its end. Forfolded blocks, the toggle is shown as .

    Commands of the Folding menu. The Folding menu can be accessed from the main menu bar (Code |Folding) or as a context menu in the editor.

    Keyboard shortcuts. The corresponding shortcuts are shown in the Folding menu.

    To expand a folded code block, in addition, you can just click the corresponding block in the editor.

    In this section:

    Configuring Autofolding Behavior

    Folding and Expanding Code Blocks

    Folding and Expanding Custom Blocks

    Viewing Contents of a Folded Block

    Folding Custom Regions with Line Comments

    See Also

    Reference:

    Editor. Colors and Fonts

    Code Folding

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Configuring Autofolding BehaviorPhpStorm allows displaying source code in a folded form, making it really concise, and hiding from view thedetails you might consider less important. When a file is first opened for editing, certain code constructs can beshown folded. It is up to you to define the desired set of code constructs to be folded by default. So doing,when you hover your mouse pointer over the collapsed code fragment, its preview is displayed in a pop-upwindow.

    To configure autofolding behavior in the editor

    1. Open the IDE settings.

    2. Under the Editor node, click Code Folding. Code Folding page is displayed.

    3. In the Collapse by default list, select the check boxes to the left of the code constructs you want to bedisplayed collapsed.

    4. Apply changes.

    Now, when you first open files for editing, the selected code constructs will be shown as shaded briefinformation, with the preview available at the mouse pointer.

    See Also

    Reference:

    Editor. Code Folding

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Folding and Expanding Code BlocksCode blocks have folding toggles at the right edge of the gutter next to each block. When a block is folded, thetoggle appears to the left of the first line of the block. When a block is expanded, the toggle is shown at thebeginning of the block and at its end.

    Folding and expanding code blocks works for entire classes, method bodies, import lists, comments, HTML andXML tags .

    To fold or expand a block of code, do one of the following

    Click the toggles or .

    Place the caret within the desired block, and choose Code | Folding | Collapse or Code | Folding |Expand on the main menu, or just press Ctrl+Plus/Minus .

    To fold or expand all blocks in a file, do one of the following

    On the main menu, choose Code | Folding | Collapse All or Code | Folding | Expand All.

    Press Ctrl+Shift+Plus/Minus .

    Pressing Ctrl+Shift+Plus once expands all blocks except the imports list. Repeating the keystrokeexpands the imports.

    See Also

    Reference:

    Editor. Code Folding

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Folding and Expanding Custom BlocksCustom code blocks can be represented either by an arbitrary selection, or code constructs not marked with thefolding toggles (for example, if or while).

    To fold an arbitrary selected block

    1. Select contiguous fragment of code in the editor.

    2. On the main menu, choose Code | Folding | Fold Selection / Remove Region, or press Ctrl+Period

    See Also

    Procedures:

    Folding and Expanding Code Blocks

    Viewing Contents of a Folded Block

    Folding Custom Regions with Line Comments

    Getting Started:

    Selecting Text in the Editor

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Viewing Contents of a Folded Block

    To view the contents of a folded block

    Hover the mouse cursor over the fold marker, and see the contents in a pop-up window.

    See Also

    Procedures:

    Folding and Expanding Code Blocks

    Folding and Expanding Custom Blocks

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Folding Custom Regions with Line CommentsWith PhpStorm, you can surround a fragment of source code with line comments. So doing, PhpStorm supportstwo styles:

    VisualStudio style

    #region Description Your code goes here... #endregion

    NetBeans style

    // Your code goes here... //

    The folding markers of a region are stored with the source code and can be shared across the team.

    Do not mix up the two styles in one file. PhpStorm will recognize the first folding comment encountered,and will assume this as a style chosen for the code.

  • To surround a custom region with folding markers

    1. Select a fragment of source code.

    2. On the main menu, choose Code | Surround With, or press Ctrl+Alt+T.

    3. Select the desired folding comments from the list:

    PhpStorm surrounds the code fragment with comments observing the syntax of the current language.

    4. If necessary, change description of the code fragment to be folded:

    You can now collapse or expand the code.

    When collapsed, the code is concealed behind the description, and you can view it by hovering your mousepointer over the description:

    Once custom regions are defined, PhpStorm provides navigation between them.

  • To navigate between custom regions

    1. Do one of the following:

    On the main menu, choose Navigate | Custom Region.

    Press Ctrl+Alt+Period.

    2. In the dialog box that opens, select the target custom region, and click OK:

    The caret rests at the comment line opening the region in question.

    See Also

    Procedures:

    Folding and Expanding Custom Blocks

    Surrounding Blocks of Code with Language Constructs

    External Links:

    Custom code folding regions

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Improving Visibility of the Source CodeThis section describes how to make your source code more clear and readable:

    Highlighting Braces

    Reformatting Source Code

    Changing Indentation

    Toggling Case

    See Also

    Procedures:

    Code Folding

    Reference:

    Advanced Editing

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Highlighting BracesThis editor feature significantly improves readability of the code, and simplifies search for unclosed blocks ortags.

    To highlight block borders

    Place the caret immediately after the block closing brace/bracket or before block opening brace/bracket.

    If the editor can find the block border, its braces, brackets or tags are highlighted with blue and a blue outlineappears in the gutter area.

    If the opening brace, bracket or tag is currently out of sight, you don't need to scroll to the beginning of theblock. The editor shows a pop-up window on top that displays the beginning of the block.

    If the editor cannot find the pair brace, bracket or tag, the unmatched one is highlighted with pink when thecaret is placed next to it, and is underlined with a red curly line.

  • Reformatting Source CodeYou can reformat source code to meet the requirements of your code style. PhpStorm will lay out spacing,indents, keywords etc. Reformatting can apply to the selected text, entire file, or entire project.

    It is also possible to apply reformatting to the parts of the source code only, using the formatting markers.

    To reformat source code

    1. On the main menu, choose Code | Reformat Code, or press Ctrl+Alt+L.

    2. In the Reformat Code dialog box, specify the reformatting scope:

    The current file.

    Selected text.

    All files in the current directory, including or omitting subdirectories. You can also include optimizingimports, by selecting the Optimize imports check box, which is enabled for the current directory only.

    3. Click Run.

    To skip a region when reformatting source code

    1. At the beginning of the region, create a line comment (Ctrl+Slash or Ctrl+NumPad /), and then manuallytype the marker specified in the Formatter off field of General page.

    2. At the end of the region, create a line comment (Ctrl+Slash or Ctrl+NumPad /), and then manually typethe marker specified in the Formatter on field of General page.

    3. Perform code reformatting, as described above.

    You can create a live template to surround a block of code with formatter off/on markers.

    See Also

    Reference:

    Code Style

    Reformat Code Dialog

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Changing IndentationPhpStorm makes it possible to:

    Indent or unindent text. This action applies to a selection, or to a line at caret.

    Choose tabs or spaces for indentation. This action applies to a selection, or the whole current file in theactive editor.

    To change indentation of a text fragment, do one of the following

    On the main menu, choose Edit | Indent Selection / Edit | Unindent Selection.

    Press Tab / Shift+Tab.

    To toggle between tabs and spaces

    On the main menu, choose Edit | Convert Indents , and then choose To Spaces or To Tabsrespectively.

    See Also

    Getting Started:

    Selecting Text in the Editor

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Toggling Case

    To toggle between upper case and lower case

    1. Select text fragment, or just place the caret at the line you want to change case in.

    2. On the main menu, choose Edit | Toggle Case, or press Ctrl+Shift+U.

    See Also

    Getting Started:

    Selecting Text in the Editor

    Web Resources:

    Discussion Forum

    Issue Tracker

  • SpellcheckingPhpStorm helps you make sure that all your source code, including textual strings, comments, and literals, andcommit messages, is spelt correctly. For this purpose, PhpStorm suggests a dedicated Typo inspection, which issupported by the corresponding bundled plugin and is enabled by default. Correctness of spelling is checked against pre-defined dictionaries (as of now, jetbrains.dic andenglish.dic), and any number of user-defined custom dictionaries.

    A user dictionary is a textual file with the dic extension, containing the words you want to be accepted by theTypo inspection as correct. The words in such dictionaries are delimited with the newline.

    Besides that, you can define your own list of words that will be skipped by the inspection. You can add words tothis list "on-the-fly", or intentionally while setting up your spellchecker options.

    With the Typo inspection enabled, PhpStorm detects and highlights words not included in dictionaries and user'swords list. It up to the user to provide correct spelling, accept word as is, or disable inspection.

    In the textual strings and comments, spelling of a word at caret can be changed to a correct one. In thecontexts that enable Rename refactoring, the inspection suggests to rename all occurrences of a symbol.

    In this section you will learn how to perform spellchecking, and configure spellchecker behavior.

    To spellcheck a word

    1. Place the caret on a word highlighted by the Typo inspection.2. Press Alt+Enter to show the available intention actions.

    3. Choose one of the following actions:

    Change to: select the desired spelling of a textual string or comment from the suggestion list.

    Save to dictionary: add word to the user's list and skip it in future.

    To configure spellchecking options

    1. Open the Project Settings dialog box

    2. Click Spelling.

    3. Make up a user's words list. To do that, click the Accepted Words tab, and use (Alt+Insert) and (Alt+Delete) to manage the list of words to be skipped by the Typo inspection.

    4. Define the set of dictionaries to be used for spellchecking on the Dictionaries tab. In the Userdictionaries paths section, click (Alt+Insert), and in the dialog that opens, select the directory wherethe desired dictionaries are located. All dictionaries detected in the specified directories, are listed in theDictionaries section below. By default, all dictionaries are enabled. If you want to omit some of them,clear their check boxes.

    5. Define the type of contents to be inspected, and inspection severity. To do that, click the Manage spellinginspection settings hyperlink to open the Typo page in Inspections. Use check boxes to define the piecesof code to be inspected (code, literals, and comments), and select severity level from the drop-down list.

    See Also

    Procedures:

    Applying Intention Actions

    Rename Refactorings

    Reference:

    Spelling

    Inspections

  • Plugins

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Using Macros in the EditorMacros provide a convenient way to automate repetitive procedures you do frequently while writing code. Youcan record, edit and playback macros, assign them a shortcut, and share them. Generally speaking, macros aredesigned for rather simple operations, and as such have the following limitations:

    Macros can be used for editor-related actions within a file.

    You cannot record such actions as button clicks, navigating to pop-up dialog boxes, and accessing toolwindows or menus.

    If a macro is intended for temporary use only, it is unnamed; permanent macros have unique names.

    This section describes how to:

    Record Macros

    Bind Macros With the Keyboard Shortcuts

    Play Back Macros

    Edit Macros

    See Also

    Concepts:

    Project and IDE Settings

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Binding Macros with Keyboard Shortcuts

    To bind a macro with a keyboard shortcut

    1. Open the Settings dialog and click Keymap.

    2. Create a new keymap or select an editable keymap from the list of keymaps.

    3. Expand the Macros node and select the macro for which a keyboard shortcut should be created.

    4. Right-click on the macro and choose Add Keyboard Shortcut in the context menu.

    5. In the Enter Keyboard Shortcut dialog, press the keys to be used as a shortcut. The keystrokes areimmediately reflected in the First Stroke field. Optionally, select the Second stroke check box andspecify the second stroke. As you press the keys, the Preview field displays the keystrokes you pressed,and the Conflicts field displays warnings, if the keystrokes are already in use.

    6. Click OK using the mouse pointer to create a shortcut and bind it with the macro.

    It is important that you use the mouse pointer, because any keystroke is interpreted as a shortcut.

    7. Click Apply to save the settings.

    See Also

    Procedures:

    Configuring IDE Settings

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Editing MacrosAfter recording, you can remove or rename any or all of the macros from the list of available macros. Theactions list of each macro is also editable - you can remove unnecessary actions.

    To edit macros

    1. On the main menu, choose Edit | Macros | Edit macros.

    2. In the Edit Macros dialog, select the macro to be edited.

    3. To change the macro name, click the Rename button, and specify the new name in the Rename Macrodialog.

    4. To change the list of actions for a macro, select an action in the action list, and click Remove Action.

  • Playing Back MacrosYou can play back the recorded macros using the Edit | Macros menu commands, or custom shortcuts.

    To play back a temporary macro

    On the main menu, choose Edit | Macros | Play Back Last Macro.

    To play back a named macro

    On the main menu, choose Edit | Macros | .

    To play back a macro with a keyboard shortcut

    1. Select a keymap with the macro bindings on the Keymap settings page.

    2. Press keyboard shortcut that corresponds to the desired macro.

    See Also

    Procedures:

    Configuring Keyboard Shortcuts

    Binding Macros with Keyboard Shortcuts

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Recording Macros

    To record a macro

    1. On the main menu, choose Edit | Macros | Start Macro Recording. From that moment on, all yourrecordable actions are recorded.

    2. When you are done with the procedure, choose Edit | Macros | Stop Macro Recording.

    3. In the Enter Macro Name dialog, specify the name of the new macro, and click OK. If the macro isintended for temporary use only, you can leave the name blank.

  • Using TODOWorking on a large project, you often need to create the lists of tasks, and keep your team mates informedabout the issues that require their attention. Such issues can include the questions that should be answered,certain changes that should be done later, areas of optimization and improvement etc.

    PhpStorm suggests to use special TODO comments in the source code. Such comments can be used in allsupported file types, and should match a certain TODO pattern. PhpStorm comes with one pre-defined pattern,but you can define as many TODO patterns as required. When a matching occurrence is encountered, it isinterpreted as a TODO item. PhpStorm highlights such comments in accordance with the Colors and Fontssettings.

    In this part:

    Defining TODO Patterns and Filters

    Viewing TODO Items

    Creating TODO Items

    TODO Example

  • Defining TODO Patterns and FiltersTODO items in the source code are defined by a certain pattern.

    Whenever a pattern is changed, or a new pattern is added, PhpStorm scans the whole project and rebuilds theindex of TODO items. Results display in the TODO tool window, as described in the section Viewing TODOItems.

    You might want to view the TODO comments of certain a type, and hide the others. For this purpose, PhpStormsuggests to use filters. This way you can show those items that match certain patterns only.

    In this section:

    Defining TODO patterns

    Defining filters

    To define a TODO pattern, follow these general steps

    1. Open the TODO page of the Settings dialog.

    2. In the Patterns section, click the Add button to create a new pattern, or the Edit button to updatean existing one. The Add/Edit Pattern dialog opens.

    3. In the Pattern field, enter the regular expression that describes the desired pattern.

    4. In the Icon list, select the desired icon that will mark the matching TODO items in the TODO tool window.

    5. Specify the color and font properties, which PhpStorm will use to highlight the matching comments in thesource code.

    6. Select the Case sensitive check box, if you want the pattern to be case-sensitive.

    To define a filter that will be used to show specific types of TODO items

    1. Open the TODO page of the Settings dialog.

    2. In the Filters section, click click the Add button to create a new filter, or the Edit button to update anexisting one.

    3. In the Add/Edit Filter dialog, specify the filter name, and select the patterns to be included in the filter.

    See Also

    Reference:

    TODO Tool Window

    TODO

    Regular Expression Syntax Reference

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Viewing TODO Items

    To view TODO items in project, follow these general steps

    1. Open TODO tool window, as described in the procedure Showing a tool window.

    The tool window displays the encountered TODO items in several tabs:

    All over the project (Project tab)

    In the file currently active in the editor(Current File tab)

    In one of the already defined scopes (Scope Based tab), which is quite useful for large projects.

    In the current changelist, if version control support is enabled.

    2. Click the desired tab (view), and explore the list of encountered TODO items. For example, with the ScopeBased view selected, one has to choose scope from the drop-down list.

    3. Narrow down the list of search results by choosing scope, and applying filters.

    See Also

    Procedures:

    Defining TODO Patterns and Filters

    Reference:

    TODO Tool Window

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Creating TODO Items

    To create TODO items

    1. Open the desired file in the editor and position the caret at the place where a TODO item should becreated.

    2. Create a comment. For example, you can use the Ctrl+Slash or Ctrl+NumPad / keyboard shortcut.

    3. In the comment, type the string that matches one of your TODO patterns. By default, any string that startswith TODO (regardless of the case) is interpreted as a TODO item and is highlighted accordingly.

    4. View the list of TODO items in the TODO tool window.

  • TODO ExampleConsider the following example: creating and viewing TODO items for each of the team members.

    Creating Patterns for TODO Items

    On the TODO page of the Settings dialog, click in the Patterns section, and create additional TODOpatterns, for example, todo-John, todo-Bob and todo-me, with new icons, and custom color schemes:

    Creating filters

    Next, create several filters, which you will use to show the TODO items, say, for each of the developers, andnot for your good self. For this purpose, in the Filters section, click , and specify the filter names, forexample, For John, For Bob, and not for me. Associate these filters with the patterns:

    Creating TODO Items in Source Code

    Now, in the source code, create TODO items: in the line of code, where you want to add a note, pressCtrl+Slash or Ctrl+NumPad /, or Ctrl+Shift+Slash or Ctrl+Shift+NumPad /, and type TODO that matchesone of the patterns, followed by some meaningful description:

  • Viewing TODO Items

    Having produced a number of TODO items across the whole project, review them in the TODO tool window:click the TODO button on the tool window bar to show the tool window. By default, all the encountered TODOitems are displayed.

    Let's now show the TODO items for Bob and John, and hide the other items: click the filter icon on thetoolbar of the TODO tool window, and select Not for me in the menu:

    See Also

    Reference:

    TODO

    Web Resources:

    Discussion Forum

    Issue Tracker

  • PhpStorm Tool WindowsAttached to the bottom and sides of the workspace are PhpStorm tool windows. These secondary windows letyou look at your project from different perspectives and provide access to typical development tasks. Theseinclude project management, source code search and navigation, running and debugging, integration withversion control systems, and many other specific tasks.

    Certain tool windows are available always, that is, in any project irrespective of the project nature, contents,and configuration. Other tool windows are available only if the corresponding plugins are enabled. There arealso tool windows that require certain specific actions to be made to become available. (For example, to makethe Find tool window available you have to search for something first.)

    In this section:

    Tool window quick access

    Tool window bars and buttons

    General tool window layout

    Accessing tool window menus

    Tool window quick access

    In the lower left corner of the workspace, there is a button which initially looks like this .

    If you point to this button, a menu opens that provides quick access to tool windows.

    Option names in this menu correspond to the names of the tool windows. When you select an option, thecorresponding tool window opens and becomes active.

  • If you click the button, tool window bars and buttons are shown. At the same time the button appearancechanges to . If you click the button again, the tool window bars and buttons are again hidden.

    Tool window bars and buttons

    When visible, the tool window button bars (or just tool window bars) are around the tool windows (or the editorarea if the tool windows are hidden). These bars contain the buttons for showing or hiding the tool windows(tool window buttons).

    The tool window buttons also provide access to tool window context menus which are shown when the buttonsare right-clicked.

    The context menus let you control the tool window viewing modes and other aspects of the tool windowappearance.

    Initially, there are three button bars, two at the sides of the main window and one at the bottom. You can showor hide all the button bars at once by clicking in the bottom-left corner of the workspace.

    Each tool window button has the name of the corresponding tool window on it. On certain buttons, the windowname may be preceded by a number, for example, 1: Project. This means that the keyboard shortcutAlt+ is available for showing or hiding the window. You can, for example, show or hide the Projecttool window by pressing Alt+1 .

    You can turn showing the window access numbers on the buttons on and off in the Appearance settings.

    The buttons for visible tool windows and for hidden ones are shown differently.

    You can rearrange the tool windows by dragging-and-dropping the tool window buttons onto a different toolwindow bar (or to a different corner of the same bar). As a result, the tool window becomes attached to thebar you've moved the window button to.

    General tool window layout

    Generally, all the tool windows are organized in a similar way.

  • At the top of the window is a title bar. When you right-click the title bar, a menu for managing the windowappearance and contents is shown.

    The title bar contains two buttons in its right-hand part. The first of these buttons ( ) opens a menu formanaging the tool window viewing modes. Note that the menu options are a subset of the title bar contextmenu.

    The second of the buttons ( ) is for hiding the tool window. When used in combination with the Alt key,clicking this button hides all the windows attached to the same tool window bar.

    Underneath the title bar are the toolbar and content pane. Depending on the window, the toolbar may be aboveor to the left of the content pane.

    The toolbar buttons, generally, are window-specific. However, the windows with similar purposes may containsimilar controls on their toolbars.

    In most cases, a function associated with a toolbar button may also be accessed from the main or contextmenu, or may have a keyboard equivalent.

    The content panes may be plain or contain two or more "layers" (views) represented, for example, by tabs.There are also tool windows with the content pane part shown on a separate tab in the editor area.

    Accessing tool window menus

  • Use the View | Tool Windows menu to show or hide the tool windows.

    Use the Window | Active Tool Window menu to perform operations related to an active tool window.These include hiding the active and other windows, changing the viewing modes for the active tool window,and more.

    See Also

    Procedures:

    Manipulating the Tool Windows

    Viewing Modes

    Speed Search in the Tool Windows

    Specifying the Appearance Settings for Tool Windows

    Configuring Keyboard Shortcuts

    Reference:

    Tool Windows Reference

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Manipulating the Tool WindowsYou can manipulate the tool windows in various ways to adjust the PhpStorm workspace to your needs.

    Showing a tool window

    Hiding an individual tool window

    Hiding all tool windows attached to the same tool window bar

    Hiding all tool windows

    Switching to the last active tool window

    Hiding or showing the tool window bars

    Attaching a tool window to a different tool window bar

    Resizing a tool window

    Increasing the maximum number of tool windows to be shown at a time

    Saving and restoring the arrangement of the tool windows

    To show a tool window, do one of the following

    In the lower left corner of the workspace, point to and select the tool window in the menu that is shown.

    Click the corresponding tool window button on the tool window bar.

    Choose View | Tool Windows | in the main menu.

    If the tool window has an associated quick access number, press Alt+ (for example, Alt+1 forthe Project tool window).

    To hide an individual tool window, do one of the following

    Click the corresponding tool window button on the tool window bar.

    Click on the tool window title bar.

    Right-click the corresponding tool window button and select Hide from the context menu.

    Right-click the tool window title bar and select Hide from the context menu.

    Choose View | Tool Windows | in the main menu.

    If the tool window has an associated quick access number, press Alt+ (for example, Alt+1 forthe Project tool window).

    If the tool window you are going to hide is currently active, press Shift+Escape.

    To hide all tool windows attached to the same tool window bar, do one of the following

    Press and hold the Alt key, and click on the title bar of any of the tool windows attached to thecorresponding tool window bar.

    Choose Window | Active Tool Window | Hide Side Tool Windows in the main menu. This commandhides all the tool windows attached to same tool window bar as the active tool window or the last of theactive tool windows.

    To hide all the tool windows, do one of the following

    Choose Window | Active Tool Window | Hide All Windows in the main menu.

    Press Ctrl+Shift+F12.

  • To switch to the last active tool window, do one of the following

    Choose Window | Active Tool Window | Jump to Last Tool Window in the main menu.

    Press F12.

    If all the tool windows are currently hidden, the last active tool window will be shown and made active.

    To hide or show the tool window bars

    You can hide all the tool window bars if you need more space in the PhpStorm window:

    In the lower left corner of the workspace, click .

    If the tool window bars are hidden, you can bring them back onto the screen either permanently or for a shortperiod of time:

    To restore the tool window bars, click in the lower left corner of the workspace.

    To see the tool window bars for a short period of time, double-press and hold the Alt key. The toolwindow bars appear on the screen making the tool window buttons accessible. The tool window bars arehidden again when you release the key.

    To attach a tool window to a different tool window bar, do one of the following

    Drag-and-drop the corresponding tool window button onto the desired tool window bar (top, left, bottom orright).

    Right-click the corresponding tool window button or the tool window title bar to open the context menu.Choose Move to and then select the destination tool window bar (Top, Left, Bottom or Right).

  • Resizing a tool window

    The obvious way to resize a tool window is this:

    Hover the mouse pointer over the tool window border. When the pointer becomes a double-headed arrow,drag the border in the required direction.

    You can also resize a tool window by moving its border to left or right, or up or down in steps. The followingalternatives are available for doing that:

    Right-click the corresponding tool window button or title bar and select Resize. Then select one of theavailable Stretch to options.

    Make the tool window of interest active and do one of the following:

    Choose Window | Active Tool Window | Resize, and then select the necessary Stretch to option.

    Press Ctrl+Shift in combination with the corresponding arrow key.

    Increasing the maximum number of tool windows to be shown at a time

    To increase the maximum number of tool windows to be shown at a time, you should appropriately set theviewing modes for different tool windows. Consider the following:

    Generally, for a tool window to be visible always (i.e. even when inactive), the tool window should bepinned.

    There are no limiting factors for the number of floating windows shown simultaneously.

    To be able to see two windows docked to the same tool window bar at a time (rather than one), one of thewindows should have the split mode off and the other one on.

    Initially, three (out of four) tool window bars are used. You can "activate" the forth tool window bar (the topone) by moving certain tool windows to it.

    Saving and restoring the arrangement of the tool windows

    You can save the way the tool window are currently arranged by choosing Window | Store Current Layoutas Default in the main menu.

    At a later time, you can return to the saved workspace layout by choosing Window | Restore DefaultLayout (Shift+F12).

    See Also

    Procedures:

    Viewing Modes

    Speed Search in the Tool Windows

    Specifying the Appearance Settings for Tool Windows

    Reference:

  • Keyboard Shortcuts and Mouse Reference

    Web Resources:

    Discussion Forum

    Issue Tracker

  • Specifying the Appearance Settings for Tool WindowsYou can change certain tool window appearance properties by specifying the corresponding Appearancesettings.

    To change the appearance properties for tool windows

    1. Open the IDE Settings and click Appearance.

    2. If necessary, change the settings related to tool window appearance. These are mainly in theTransparency and the Window Options sections. For more information, see the description of theAppearance page.

    See Also

    Procedures:

    Manipulating the Tool Windows

    Viewing Modes

    Speed Search in the Tool Windows

    Reference:

    Tool Windows Ref