A look into the high-level programming operations for the PHP language

Instant PhpStorm Starter

February 2013


Learn professional PHP development with PhpStorm

(For more resources related to this topic, see here.)

Accessing documentation

PhpStorm offers four different operations that will help you to access the documentation: Quick Definition, Quick Documentation, Parameter Info, and External Documentation. The first one, Quick Definition, presents the definition of a given symbol. You can use it for a variable, function, method, or class. Quick Documentation allows easy access to DocBlocks. It can be used for all kinds of symbols: variables, functions, methods, and classes. The next operation, Parameter Info, presents simplified information about a function or method interface. Finally, External Documentation will help you to access the official PHP documentation available at php.com.

Their shortcuts are as follows:

  • Quick Definition (Ctrl + Shift + I, Mac: alt + Space bar)

  • Quick Documentation (Ctrl + Q, Mac: F1)

  • Parameter Info (Ctrl + P, Mac: command + P)

  • External Documentation (Shift + F1, Mac: shift + F1)

The Esc (Mac: shift + esc) hotkey will close any of the previous windows.

If you place the cursor inside the parenthesis of $s = str_replace(); and run Parameter Info (Ctrl + P, Mac: command + P), you will get the hint showing all the parameters for the str_replace() function. If that is not enough, place the cursor inside the str_replace function name and press Shift + F1 (Mac: shift + F1). You will get the manual for the function.

If you want to test the next operation, open the project created in the Quick start – your first PHP application section and place the cursor inside the class name Controller in the src/My/HelloBundle/Controller/DefaultController.php file. The place where you should place the cursor is denoted with bar | in the following code:

class DefaultController extends Cont|roller { }

The Quick Definition operation will show you the class definition:

The Quick Documentation operation will show you the documentation defined with PhpDoc blocks:

It is a formal standard for commenting on the PHP code. The official documentation is available at http://www.phpdoc.org.


PhpStorm enables you to do the following:

  • Implement magic methods

  • Override inherited methods

  • Generate constructor, getters, setters, and docblocks

All of these operations are available in Code | Generate (Alt + Insert, Mac: command + N). Perform the following steps:

  1. Create a new class Foo and place the cursor at the position of | :

    class Person { | }

  2. The Generate dialog box will contain the following operations:

    The Implement Methods dialog box contains all available magic methods:

  3. Create the class with two private properties:

    class Lorem { private $ipsum; private $dolor; }

  4. Then go to Code | Generate | Getters and Setters. In the dialog box select both properties:

  5. Then press OK. PhpStorm will generate the following methods:

    class Lorem { private $ipsum; private $dolor; public function setDolor($dolor) { $this->dolor = $dolor; } public function getDolor() { return $this->dolor; } public function setIpsum($ipsum) { $this->ipsum = $ipsum; } public function getIpsum() { return $this->ipsum; } }

  6. Next, go to Code | Generate | DocBlocks and in the dialog box select all the properties and methods:

  7. PhpStorm will generate docblocks for each of the selected properties and methods, for example:

    /** * @param $dolor */ public function setDolor($dolor) { $this->dolor = $dolor; }


We just learned that in some cases you don't have to type the code at all, as it can be generated automatically. Generators discussed in this article lifted the burden of type setters, getters and magic functions from your shoulders. We also dived into different ways to access documentation here.

Resources for Article :

Further resources on this subject:

Books to Consider

comments powered by Disqus