PHPStorm自动完成对视图文件的CakePHP定制的助手 [英] PHPStorm autocomplete for CakePHP custom helpers in view files
问题描述
我用PhpStorm 6.0.2和CakePHP 2.3。
I use PhpStorm 6.0.2 and CakePHP 2.3.
在我的控制器文件,我定义这一点,并自动完成得为我的自定义组件:
In my controller file I define this and get autocomplete for my custom components:
/**
* @property MysuperComponent $Mysuper
*/
关于以这个,在我看来,我的文件定义此到达蛋糕的核心助手和这个作品:
Regarding to this, in my view files I define this to reach Cake's core helpers and this works:
/**
* @var $this View
*/
我需要自动完成对我的看法里定制的助手。我试过,但没有工作:
I need autocomplete for custom helpers inside my views. I tried this but didn't work:
/**
* @property Myelegant $MyelegantHelper
*/
当我这样做,这部分工作:
When I do this, this works partially:
/**
* @var $Myelegant MyelegantHelper
*/
我得到这个 $ Myelegant->
自动完成。但它是不够的。我需要自动完成这样的: $这个 - > Myelegant->
I get this $Myelegant->
autocomplete. But it isn't adequate. I need autocomplete like this: $this->Myelegant->
注:自动完成成功适用于核心助手内视图(CTP)文件。但不适合定制的助手。
Notes: Autocomplete successfully works for core helpers inside view (ctp) files. But not for custom helpers.
推荐答案
添加新的文件/app/View/HintView.php结果
加上PHPDoc的您定制的助手的名字。
Add new file /app/View/HintView.php
Add your custom helpers' names on PHPDoc.
<?php
App::uses('View', 'View');
/**
* @property MyelegantHelper $Myelegant
* */
class HintView extends View {
}
在您的布局文件或查看文件(CTP文件)添加在上面这个code
Inside your layout files or View files (ctp files) add this code on top
/**
* @var $this HintView
*/
现在你的意见在里面可以看到这样的:
Now inside your views you can see like this:
$this->MyElegant
->Blocks
->Cache
->Form
$this->MyElegant->somefunction()
anotherfunction()
oldfunction()
您不必从HintView扩展您的意见。这只是PhpStorm的自动完成。
You don't have to extend your Views from HintView. It is only for PhpStorm's autocomplete.
(请注意,您可以用C $ CS创建快捷方式到$使其更快。比如转到Settins / IDE设置/的现场模板添加新的模板。例如,myeleg为 $这个 - &GT; MyElegant-&GT;
所以,当你写myeleg和preSS Tab键将会写入类名自动)
(Note that you can make it faster with creating shortcuts to codes. For example goto Settins / IDE Settings / Live Templates. Add new template. For example "myeleg" for "$this->MyElegant->
" So when you write "myeleg" and press Tab key it will write the class name automatically)
这篇关于PHPStorm自动完成对视图文件的CakePHP定制的助手的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!