How to use the Phpstorm development tools gracefully

Source: Internet
Author: User
Tags how to use git ssl connection

Phpstorm is a lightweight and convenient PHP IDE designed to provide user efficiency, a deep understanding of the user's coding, smart code completion, quick navigation, and instant error checking.

Introduction: Phpstorm is a commercial PHP integrated development tool developed by JetBrains company. Phpstorm can help users adjust their coding at any time, run unit tests or provide visual debug functionality and intelligent html/css/javascript/php editing, Code quality analysis, versioning integration (SVN, GIT), debugging, and testing. In addition, it is a cross-platform. Can be used under both Windows and MacOS. Phpstorm-makes development smarter, not more difficult.

Advantages
    1. Cross-platform.

    2. Supports refactor functionality for PHP.

    3. Automatic generation of Phpdoc annotations makes it easy to do large-scale programming.

    4. Built-in support Zencode.

    5. Generates an inheritance diagram of a class that, if it has a class, can be used to view all of his parent relationships after multiple inheritance.

    6. Support code refactoring for easy code modification.

    7. Local history feature.

    8. A convenient deployment that directly upload the code directly to the server.

Anyway, it's a good thing.

Shortcut keys

Phpstorm has very very many and easy to use shortcut keys, I would like to give some frequently used shortcut key demonstration, there are some not commonly used for example, can definitely improve the effectiveness of your development rate ...

(Windows is similar to a Mac, just command replace the keys ctrl )

Query related
    • command + fFind current File

    • command + rFind replacements

    • command + eOpen a recent file

    • command + shift + oQuick Query File

    • command + shift + fKeyword lookup, more powerful finder (the machine is not good, it is better to determine the directory first)

    • command + shift + rAdvanced Replacement

    • command + alt + bFind all subclasses of the cut class

    • alt + shift + cFind recently modified files

    • alt + f7Querying the selected characters directly

    • ctrl + f7Query for selected characters in file

    • command + 鼠标点击Jump to a declaration such as a class or method or variable

    • command + shift + tabToggle Tab File

    • command + shift + +,-Expand or shrink

    • command + .Collapse or expand the selected code

Automatic code
    • alt + 回车Import package, auto fix

    • command + nJoy generate getter and setter methods for each member property

    • ctrl + iQuick Build Insertion Magic method

    • ctrol + oReplication Parent class method

    • command + alt + lFormatting the current file

    • command + dCopy when cut line

    • command + /Comments

    • command + shift + // /Notes

To command + n give an example

I created a Person class in the /Entity/ directory, and then I set some private properties to the following code:

Namespace Entity;class person{    private $sign = ';    Private $name = ';    Private $age  = 0;        Private $work = ';        Private $sex  = ' woman ';}

Then we use the command + n pop-up window to select "PHPDoc Blocks ..." Such as:

Then pop up the window and select all the properties and click "OK":

namespace entity;/** * Class person * @package Entity */class person{    /**     * @var String */    Private $sign = ";    /**     * @var String */    private $name = ';    /**     * @var int */    private  $age = 0;    /**     * @var String */    private $work = ';        /**     * @var String */    private  $sex = ' female ';}

It then adds a comment to the property you just selected ... is not gray often magical.

OK, let's go ahead and use the key again to command + n select Contructor... the properties that need to be assigned to the parameter:

    /**     * Person constructor.     * @param string $sign     *    /Public Function __construct ($sign)    {        $this->sign = $sign;    }

If you do not choose, you will not need to set the member properties.

Then let's look at other features, such as "Implement Methods ..." which is a quick way to generate magic.

It is usually better not to set parameters or get parameter values directly in this way when we set up a member property, it $person->name = $name is recommended to open a follow method for each property, getter setter so it is convenient to handle the values passed in or out. That's one of the reasons why I want to set the member property to private.

The same command + n choice "Getters and Stetters" and then select all the properties, it will put all the property settings getter and setter methods, here to pay attention to is Person sign unique, can not be modified, so we have to set sign method is removed. Note: The best setter way to do this is to return to the cutting object, so that we can ligatures and phpstorm the hints are quite friendly. Here are some examples:

    /** * @return String */Public Function getsign () {return $this->sign;    }/** * @return String */Public Function GetName () {return $this->name;  }/** * @param string $name * @return $this */Public Function SetName ($name) {$this->name        = $name;    return $this;    }/** * @return int */Public Function getage () {return $this->age; }/** * @param int $age * @return $this */Public Function setage ($age) {$this->age = $age        ;    return $this;    }/** * @return String */Public Function getwork () {return $this->work;  }/** * @param string $work * @return $this */Public Function setwork ($work) {$this->work        = $work;    return $this;    }/** * @var String */private $sex = ' female '; /** * @return String */Public Function getsex () {       return $this->sex; }/** * @param string $sex * @return $this */Public Function Setsex ($sex) {$this->sex = $                Sex    return $this; }

Examples of ligatures:

Use Entity\person, $person = new Person (), $person->setname ("egg")    ->setage (+)    ->setwork (' student ') ;

Finally, the function of a fast replication inherited class is demonstrated. We create a new Man class and then inherit the Person class, the person class above is a female, so we need to rewrite it and add "Chinese man". Same Use command + n Open shortcut window to select "Override Methods ..." The way to bounce it out can be replicated:

Then we choose to getSex follow the setSex method and then make sure that the following methods are Man generated under the method.

Namespace entity;/** * Class man * @package Entity */class man extends person{    /**     * @return String */    P ublic function Getsex ()    {        return parent::getsex ();//Todo:change the autogenerated stub    }    /**     * @param int $sex     * @return $this     *    /Public Function setsex ($sex)    {        return Parent:: Setsex ($sex); Todo:change the autogenerated stub    }}

Let's return parent::getSex() return parent::setSex( $age ) delete it, we don't need it, and then we change it to the following pattern.

  /**     * @return String */public    function getsex ()    {        if (! Mb_strpos (Parent::getsex (), "China"))            Return to "China". Parent::getsex ();        return Parent::getsex ();    }    /**     * @param int $sex     * @return $this */public    function setsex ($sex)    {        if (! Mb_strpos ($ Sex, "China")            $sex = "China". $sex;        Return Parent::setsex ($sex);    }
Tools and other Products

Looks like a lot of paper, I am lazy, do not want to talk about it? I'll just pick a few, okay?

    • It's easy to match the SSH.

    • Composer This is also very clear, not much to say, usually we are through the command line to achieve

    • Vagrant this phpstorm 10 set into vagrant, in between we have built their own vagrant environment, do not use Phpstorm integrated

Reference: Building the development environment using virtual box and vagrant

Database Tools

Phpstorm Integrated Database tool is very powerful, of course, it also has a separate database tool called: Datagrip, of course, need to buy separately, we phpstorm have integration, we use it good haha .... (Our phpstorm is paid for, please support the genuine)

Database tools are generally on the right side of the column, if not the search is good, how simple things ah ...

Start creating a database connection ...

Select the "+" number, then select the Data Source data source, and then select the database type, generally we use MySQL bar, this time we try new, such as SQLite

Choose sqlite the address of the data file, and then select the driver, if not the first to download the installation of SQLite driver plug-in, this is very simple, in the driver under the hint, do it ...

Let's look at the configuration of MySQL ...

MySQL is also very simple, if you need SSH/SSL connection, you need to match the address in the Ssh/ssl tab on the connection password or sshkey ...

Prepared, open the selected database:

Are Tables and table field information for the connected database ... To demonstrate the query ... Clicking on the "QL"-like DOS window icon will pop up a tab page where we can write the SQL statement.

We check User all the data under the table, we can see that there will be quite a hint, it is quite good ... After the query is completed, the following Database Console will show the table data, you can modify it, and so on, and so on to add data.

Shortcut keys command + alt + l not only format the code, but also the SQL statement is very effective, such as.

On the Database Console bar, click the Output tab to view information such as the execution of the SQL statement, the record and the time spent, and so on ...

    • command + 回车Execute the SQL statement or execute the selected SQL statement

About the use of database tools There are many, I do not explain, we can study slowly, really very useful

CVS and Git
    • command + k

    • command + shift + k

About the configuration of FTP, because I do not recommend the use, so there is not much to say!

It's all here, so let's talk about how to use git tools on phpstorm.

Forget, or give an example, with spicy is too tired, a will I see if there is already well, if there is a will pull out to take a look at the map to see it, anyway, now svn with less, or git with cool, distributed well, offline, how good ... About SVN-Git can refer to an article I wrote earlier

Migrating the code base from SVN to Git

Catch the code locally from the GIT server

ChooseCVS -> Checkout from Version Control -> Git

Enter your git repository information in the popup window:

Note that Conle time if you do not set up your GitHub account, you may be prompted to enter the account information, we will enter the line. If you need to change it, you can change it in the settings, and we'll use " command + , GitHub" to open "Preferences" and find the "Version Control" option, as well as the "Git" path.

Create a branch from Mster

To create a branch to be created from the command line, we can create it from the Phpstrom window, as follows:

This thing in the bottom right corner, "Git:master" then pop up the window above select "New Branch" and then enter the name of the new branch, it will automatically switch to the new branch.

Isn't it super simple ...

Submit Code to Remote branch

When we have modified the code, we need to submit the code to the remote branch, using the shortcut key to command + k submit a fairly modified code, double-click the file can be compared. When the "commit Message" writes the modified item and then submits it, the code is submitted to the local branch.

If you do not use the shortcut key, you can use the "CVS---Commit changes" submission, you will also pop up the following window ...

?

After committing to the local branch, we need to push the code to the remote branch, so we need to use the shortcut key: command + shif + k Submit Remote Branch ...

?

You can also use the "CVS-, Git-and Push" to commit ... The effect is the same

Note that SVN wood has command + shift + k this step

Merging branches

is very simple, just select the branch that needs to be merged, and then merge is OK, such as:

This completes the merger, of course, if there are conflicting words will be submitted there is a conflict, and let you solve, if not, the direct merger succeeded ... Then you can push ...

Compareis to compare the merged branches ...

Use SVN ...

Gray often sorry, my computer has found the relevant SVN project code, not much to say ...

Installing plugins

Here is a JavaScript installation, using shortcut keys to cmd + , open preferances

Installing JavaScript Plugins

Languages & Frameworks, JavascriptLibraries

Select the frame you want to add

Install Symfony2 plug-ins, search for plugins, then click Install

And then restart the phpstorm.

Attention
    • Gray + wavy Line: variable not used

    • Yellow wavy Line: Variable unnamed word spelling problem

    • Red wavy Line: variable not defined

    • There are a lot of me not one of the examples, probably because I write too good code, wrong things less ...

The right column appears red, this is a must to eliminate, good code should not appear red any hint ... Once the appearance must be resolved immediately, the good code should not appear a yellow, red hint.

TODO represents a to-do event that, when submitted to VCs, SVN, or git, prompts for an unhandled event and requires confirmation of the commit.

Write a bit more, want to write more things, or divided into two write well? Forget it, I'm lazy, just like that, after I want to write it again, thank you for reading!!!!!

In fact, there are a lot of things to write, I just want to lazy ...

How to use the Phpstorm development tools gracefully

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.