PHP Tools For Vs User
PHP Tools For Vs User
com/products/php-tools
- 1-
www.devsense.com/products/php-tools PHP Editor Options ...................................................................................................................................... 17 Debugging PHP code ................................................................................................................................... 17 Troubleshooting .......................................................................................................................................... 17 All the PHP code is gray ........................................................................................................................... 17 Unable to change some colors in VS11/Visual Studio 2012 RC .............................................................. 18 Cannot obtain a trial license .................................................................................................................... 18 Cannot activate professional features after the purchase...................................................................... 18 Slow or unstable PHP Editor .................................................................................................................... 18 Some of functions within my project are not included in IntelliSense lists ............................................ 19 Contact ........................................................................................................................................................ 19
- 2-
www.devsense.com/products/php-tools
Introduction
PHP Tools is lightweight PHP integration for Visual Studio focused on developer productivity. The integration understands your code, provides smart code completion, quick navigation, syntax error checking, integrated PHP documentation and more.
About
PHP Tools for Visual Studio is Visual Studio extension which adds PHP files code editor and project and item templates. The extension is based on .NET platform, focused on performance and stability. Support for integrated debugger is in-progress.
Requirements
Microsoft Visual Studio 2010, 2011 o Ultimate o Premium o Professional o (free) Integrated Shell 2GB RAM 1.4GHz dual-core processor Internet connection for additional features activation
Installation
The tool is distributed in a form of VSIX installation package. VSIX package is natural way of extending Visual Studio with additional features, can be easily installed and uninstalled without footprint on the target system. There are two ways of obtaining and installing PHP Tools integration: Extension can be installed from within Visual Studio (recommended). Open your Visual Studio, navigate to Tools -> Extension Manager -> Online Gallery and search for PHP Tools (see Figure 1 Installing PHP Tools from Extension Manager.). Visual Studio will offer you available products, you can continue to download and installation within one click. Note youll have to restart Visual Studio to finish the installation.
- 3-
www.devsense.com/products/php-tools
The package can be downloaded from Visual studio Gallery web and installed manually. Download package from http://visualstudiogallery.msdn.microsoft.com/6eb51f05-ef01-4513ac83-4c5f50c95fb5, run the downloaded file and follow on-screen instructions (see Figure 2 Installing PHP Tools using downloaded VSIX package.). Note it is recommended to close Visual Studio before installing. VSIX installer will show you whether there are Visual Studio products available for the package and whether there arent newer versions of the package already installed.
- 4-
www.devsense.com/products/php-tools
Updating
To update the extension, you can either re-download VSIX package (see Installation) and run the installation manually, or take advantage of Visual Studio Extension Manager and its Updates tab (in Visual Studio, navigate to Tools -> Extension Manager -> Updates). Automatic update notification To be automatically notified about available updates, enable Automatically check for updates to installed extensions option (see Figure 3 Enabling automatic updates). This can be found in Options dialog in Visual Studio (navigate to Tools -> Options).
- 5-
www.devsense.com/products/php-tools
- 6-
www.devsense.com/products/php-tools
- 7-
www.devsense.com/products/php-tools
- 8-
www.devsense.com/products/php-tools
You can open several projects within one solution. This allows you to manage more projects within one Visual Studio instance and to work between more PHP web sites.
PHP Editor
PHP Editor integration adds support for .php files into Visual Studio, and an option to specify additional file extensions (see Custom file extensions). This support makes PHP code highlighted, with additional features listed in this section. As of May 2012, PHP 5.3 compatible constructs are supported.
- 9-
www.devsense.com/products/php-tools
Syntax highlighting
Syntax highlighting feature makes PHP code more readable as any other language file integrated in Visual Studio. Script code blocks, variables, keywords, strings, script tags and comments are distinguished to make programming easier. When PHP Editor finds a syntax error or a logical error, corresponding expression is underlined with red wave and the error detail is listed in Visual Studios Error List tool window.
Custom colorization
PHP Tools editor respects your custom color settings from Visual Studio. These settings can be configured in Tools -> Options -> Environment -> Fonts and Colors (see Figure 8).
- 10-
www.devsense.com/products/php-tools The editor uses all built-in settings. This lets you to use PHP Editor with your existing custom settings easily. Following Display items affects PHP Tools Editor
Keyword Affects PHP keywords, such as for, while, if, function. Comment Color of inline comments and content of PHPDoc. Identifier Any identifier, such as a function name or a class name. String Color of string literals, enclosed in or quotes. Number Numeric literal. Text Other simple symbols, including commas and operators. HTML Server-Side Script PHP starting and ending scripting tags (<?php ?>) HTML Attribute Name Color of HTML attribute name. HTML Attribute Value Color of HTML attribute value. PHP - Encapsulated Variable Color of a variable name within a string literal. PHP - Variable Color of variable name. That is typically a symbol starting with $ character. PHP PHPDoc Keyword Color of special keywords and comment tokens within PHPDoc.
Smart Indentation
PHP editor supports smart indentation feature. It should be enabled by default, otherwise go to Tools -> Options -> Text Editor -> PHP -> Tabs, and select Smart in the Indenting options group. Smart Indenting automatically indents or outdents new lines. It recognizes what you are actually typing: <enter> key will place your caret to the best position for new statement or for continuing unfinished statement. This also works within PHPDoc or multi-lined comments, by adding * at the line beginning. { character outdents current line to line up with code block start. } character outdents current line to match block start. If the code is syntactically valid, it also reformats code block (see Automatic Formatting). : after case or default makes indentation of the line the same as other cases within the switch.
Automatic Formatting
You can fix indentation and code formatting automatically by pressing Ctrl+K,D. This will reformat PHP code within the whole document, and adds additional new lines where they should be, to make your code more readable and to preserve formatting conventions across the whole project. PHP editor also supports reformatting of a text selection only. Select code fragment and press Ctrl+K,F to reformat only a piece of code. Formatting selection is called automatically on code blocks that you just closed with } character (you can always disable this feature in PHP Editor Options). Automatic Formatting respects common programming conventions and Visual Studio conventions. It keeps your new line breaks, keeps single-lined <?php ?> blocks and your custom indentation settings.
- 11-
www.devsense.com/products/php-tools
Navigation bar
Every PHP file gets navigation bar at the top of editor. This bar shows two drop-down lists: Type list shows classes and interfaces within current file. You can quickly navigate to a class or interface definition by selecting it from the list. Member list shows either global functions (if no type is selected in the first list) or list of toplevel class members (if a type is selected in the first list). Every listed symbol is marked with an icon, name and occasionally parameters in case of a function. In case of class member, only toplevel members are listed; members in parent classes are ignored.
PHP Editor allows you to collapse functions, classes, namespaces and PHPDoc to make better overview of your code. By default, Collapse to definition is associated with shortcut Ctrl+M,O, and disable outlining with Ctrl+M,P. If you have a cursor inside a collapsible block (which is represented by a thin line on the left side of editor) you can press Ctrl+M,M to toggle its state.
Code Snippets
PHP Editor supports snippets; small pieces of most used code fragments to be inserted within as little keyboard hits as possible to save time and avoid common typos. Most used code snippets are if, for or switch. By inserting these keywords as snippet, whole standard body of the statement is inserted instead.
- 12-
Snippets can be inserted in two ways: Snippets browser. Small tool window with list of available snippets can be opened anywhere in PHP code. By subsequent typing, selecting and pressing enter key, code snipped is inserted at the current caret position. By default, snippet browser is opened by pressing Ctrl+K,X or by mouse right click and choosing Insert Snippet command. Inserting snippets only works within PHP code block. Code completion drop down. Code snippets are included as a part of code completion list (see Code completion). Keywords supporting snippet insertion are marked with special icon. By pressing tab key the keyword is inserted as a snippet.
Surround with In addition to inserting clean snippets, you can surround an existing code with the snippet code. It is very useful feature allowing you to easily create e.g. function, a loop or try block around an existing code. To choose a snippet you would like to use, press Ctrl+K,S (default) or use right mouse click and select Surround with command. Snippet browser will pop up, and chosen snippet will surround selected text.
Integrated documentation
PHP editor contains database of built-in PHP functions, classes and constants, contained in every official PHP extension. Every symbol is annotated with detailed documentation. This means youll see description of anything you are selecting from IntelliSense lists or mouse hovering. When you are typing, PHP Editor shows a list of available symbols within your current code context. After highlighting a symbol in the list, tool tip bubble is displayed aside of the drop down list with complete symbol declaration and its description. This makes you easier to check anything you are about to use, without a need of navigating to documentation on web. - 13-
www.devsense.com/products/php-tools
Mouse hovering over a word (functions, class name or a class) shows the same tool tip bubble, so you can ensure about functionality of code you are using instantly. Go To Definition (F12) PHP Editor also supports Go To Definition feature. Right click on a word or simply press F12 to navigate to a symbol definition. By navigating to a definition of built-in PHP declaration, PHP Editor will generate PHP code corresponding to its specification, including its documentation (as VisualStudio developers are used to). F1Help (F1) Built-in PHP functions, classes and class functions can navigate you to PHP manual page directly. Place a caret cursor onto the desired symbol and press F1. This will open your web browser at corresponding page so you can find more details, related declarations or users discussion.
Code completion
When typing a word, PHP Editor popups list of possible symbols that would autocomplete so-far typed word. The list also shows associated documentation obtained from built-in symbol database or related PHPDoc comments. Auto-completion takes into account current code context and the whole expression chain.
- 14-
www.devsense.com/products/php-tools Note: this feature works for global code, local code, namespaces, variables, constants, classes, functions, instance members and class static members. All listed symbols are estimated using code analysis; some symbols may be missing or there can be listed symbols that would not be present in run-time. To make code completion as precise as possible, write PHPDoc with @return type specified, @var type, use unique names of variables and in general; write code clean. Code completion after keywords such as new, global, extends or implements shows only symbols available in this context. Code completion can be always displayed at any location by pressing Ctrl+Space (by default). Code completion, tool tip assistance, function assistance and Go To Definition features need information about files in your PHP project. All the project files are processed every time you open PHP project and use one of the feature above for the first time. This may take some time, and you will be notified about the progress in Visual Studios status bar at bottom of window. During the processing some of symbols may not be displayed within IntelliSense lists or may not be available in for other code sense features.
Go To Definition (F12)
PHP Editor supports Go To Definition feature which navigates you to definition of symbol under the cursor. This feature recognizes following symbols: In case of variables, youll be navigated to all estimated variable initialization expressions. This represents common way of declaring variables in PHP. Indirect variable usages are ignored. Navigating over a function call offers definitions of all functions with the name under the cursor. All the Classes with the name specified under the cursor are offered. Constants within define() function call or const declaration statement are recognized. Class members of object instances and static members of types are supported. Note the type of class instance has to be estimated, and more or none results can be offered based on the estimation.
If there is just one possible result, youll be navigated instantly. In case of none or more than one result, Find Symbol Results window is opened so you can select one or cycle through all of them.
Function assistance
By typing ( or , characters, PHP Editor looks onto code and shows information about function before the cursor. In the showed bubble (see Figure 13 Method info bubble.) you can see all the possible function overloads in case there would be more possibilities in run time.
- 15-
www.devsense.com/products/php-tools The bubble contains function name, documentation if available, and parameters with estimated types and initial values for optional ones. Every parameter can also be tagged with documentation.
The feature can be configured within Visual Studio, go to Tools -> Options -> Text Editor -> File Extensions. Enter your file extension in the text box, select PHP Editor from the list and click Add. The configuration dialog is depicted on Figure 14 Additional file extensions configuration. Note it is recommended to restart Visual Studio to be sure your changes are accepted by opened projects within your Solution Explorer.
- 16-
www.devsense.com/products/php-tools
PHP editor is configurable in Tools -> Options -> Text Editor -> PHP. See Figure 15 PHP Text Editor options. You can modify indentation behavior, whether <tab> key inserts tabulator character or spaces and other options.
Troubleshooting
All the PHP code is gray
This issue is mostly caused in two cases. The PHP Tools extension is not installed or is disabled. Within Visual Studio, navigate to Tools -> Extension Manager, and check whether you have PHP Tools installed, whether there are no conflicts with other PHP extensions and whether the extension is not disabled. Note when enabling extension, other running instances of Visual Studio may cause disabling it again. Default editor for PHP files has been changed. Sometimes users without PHP integration configure their Visual Studio to open PHP files with HTML editor or XML editor instead. PHP Tools are not able then to control PHP files. To fix this, go to File -> Open -> File, navigate to any .php file on your system, and click Open With (small black arrow aside of Open button). - 17-
www.devsense.com/products/php-tools
In the opened dialog select Source Code (Text) Editor or PHP Editor and click Set as Default.
- 18-
www.devsense.com/products/php-tools
Contact
PHP Tools for Visual Studio is developed and supported by DEVSENSE. http://www.devsense.com/products/php-tools - product web site, features, pricing, demos. http://www.devsense.com/ - company web site. http://visualstudiogallery.msdn.microsoft.com/6eb51f05-ef01-4513-ac83-4c5f50c95fb5 - Visual Studio Gallery, rating, downloads, statistics, current version download.
- 19-