Home  >  Article  >  Backend Development  >  关于PHPstorm 使用技能

关于PHPstorm 使用技能

WBOY
WBOYOriginal
2016-06-13 12:29:24877browse

关于PHPstorm 使用技巧

慢慢更新,一点点积累,都是自己在使用中遇到的问题

设置:(2016.4.15)

1:注释模板,phpstorm 有非常强大的注释模板,可以根据自己的需求随时更改,并设置快捷键,非常方便

 新文件注释 PHP File Header

<span style="font-family: Microsoft YaHei;"><span style="color: #000000;">php</span><span style="color: #008000;">/*</span><span style="color: #008000;">* * Created by PhpStorm. * User: Administrator * Date: 2016/4/13 * Time: 22:44 </span><span style="color: #008000;">*/</span></span>

类注释 PHP Class Doc Comment

<span style="font-family: Microsoft YaHei;"><span style="color: #008000;">/*</span><span style="color: #008000;">* * Class index * * @package application\controller * @VERSION 1.3 * @AUTHOR  mask </span><span style="color: #008000;">*/</span><span style="color: #0000ff;">class</span> index <span style="color: #0000ff;">extends</span><span style="color: #000000;"> controller{</span></span>

函数注释 PHP Function Doc Comment

<span style="font-family: Microsoft YaHei;">    <span style="color: #008000;">/*</span><span style="color: #008000;">*获取配置类对象     *author : stubborRookie     *     * @return config     *version :1.3     </span><span style="color: #008000;">*/</span>    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">function</span><span style="color: #000000;"> config()    {        </span><span style="color: #0000ff;">return</span> <span style="color: #0000ff;">new</span><span style="color: #000000;"> config();    }</span></span>

自定义自己的模板:

File->setting->editor->File and code Templates

根据里面的规则可以设置不同的显示字段

自定义字段:

在注释中使用自己的名字通常是 ${USER} 但是这个默认是计算机的名称,怎么改成自己的呢

可以选择 Includes 选项卡,然后点击面板左上角 + 号新建一个模板 取名:PHP define(可以自定义) 扩展名 php

然后在里面写上如下代码:

<span style="font-family: Microsoft YaHei;"><span style="color: #008000;">#</span><span style="color: #008000;">set ($VERSION="1.3")</span><span style="color: #008000;">#</span><span style="color: #008000;">set ($USER='stubbornRookie')</span></span>

定义好变量并赋值,在需要用到该变量的模板中引入,如:

<span style="font-family: Microsoft YaHei;"><span style="color: #008000;">#</span><span style="color: #008000;">parse("PHP define.php")</span><span style="color: #008000;">/*</span><span style="color: #008000;">* author = ${USER}** version =${VERSION}</span><span style="color: #008000;">*/</span></span>

这样子就可以了!

在需要注释的地方,比如方法名上面 输入 /** 然后按 Ctrl+enter 就会自动完成注释!

编辑器字体

在editor里都可以设置,设置中需要复制一份才能设置。

 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn