php – 如何设置Eclipse PDT遵循Zend Framework 2编码约定?
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了php – 如何设置Eclipse PDT遵循Zend Framework 2编码约定?,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含6365字,纯文字阅读大概需要10分钟。
内容图文
![php – 如何设置Eclipse PDT遵循Zend Framework 2编码约定?](/upload/InfoBanner/zyjiaocheng/787/a587067191a847318d819d5417d5601d.jpg)
我正在学习Zend Framework 2.当我按下Ctrl Shift F组合自动格式代码的键时,它显示不像Zend Framework 2编码惯例.请给我一个简单的方法来自动格式化代码遵循Eclipse 4.4 Luna PDT(PHP开发工具)中的Zend Framework编码约定.
解决方法:
我曾经使用Eclipse和PDT一段时间.然后我切换到另一个IDE.无论如何,在Eclipse中,您可以编辑autoformat的工作方式.您可以在窗口中编辑Autoformat – >首选项然后在PHP下 – >代码风格.对我来说,它从一开始就与Zend Framework 2一起运作良好.
在那里,您还可以找到导出/导入设置的可能性.我刚出口我的.
您可以将以下代码保存为.xml,然后将其导入到您能够编辑设置的相同位置.希望这可能会对你有所帮助.
不要忘记,首先要备份你的,只是为了确定. (我使用Eclipse 4.2.2& PDT 3.1.1)
代码模板的XML
<?xml version="1.0" encoding="UTF-8" standalone="no"?><templates><template autoinsert="true" context="php_gettercomment_context" deleted="false" description="Comment for getter methods" enabled="true" id="org.eclipse.php.ui.editor.templates.php.codetemplates.gettercomment" name="gettercomment">/**
* @return the ${bare_field_name}
*/</template><template autoinsert="true" context="php_settercomment_context" deleted="false" description="Comment for setter methods" enabled="true" id="org.eclipse.php.ui.editor.templates.php.codetemplates.settercomment" name="settercomment">/**
* @param ${field_type} ${bare_field_name}
*/</template><template autoinsert="true" context="php_constructorcomment_context" deleted="false" description="Comment for created constructors" enabled="true" id="org.eclipse.php.ui.editor.templates.php.codetemplates.constructorcomment" name="constructorcomment">/**
* ${tags}
*/</template><template autoinsert="true" context="php_filecomment_context" deleted="false" description="Comment for created PHP files" enabled="true" id="org.eclipse.php.ui.editor.templates.php.codetemplates.filecomment" name="filecomment">/**
*
*/
</template><template autoinsert="true" context="php_typecomment_context" deleted="false" description="Comment for created types" enabled="true" id="org.eclipse.php.ui.editor.templates.php.codetemplates.typecomment" name="typecomment">/**
* @author ${user}
*
* ${tags}
*/</template><template autoinsert="true" context="php_fieldcomment_context" deleted="false" description="Comment for fields" enabled="true" id="org.eclipse.php.ui.editor.templates.php.codetemplates.fieldcomment" name="fieldcomment">/**
* @var ${field_type}
*/</template><template autoinsert="true" context="php_methodcomment_context" deleted="false" description="Comment for non-overriding methods" enabled="true" id="org.eclipse.php.ui.editor.templates.php.codetemplates.methodcomment" name="methodcomment">/**
* ${tags}
*/</template><template autoinsert="true" context="php_overridecomment_context" deleted="false" description="Comment for overriding methods" enabled="true" id="org.eclipse.php.ui.editor.templates.php.codetemplates.overridecomment" name="overridecomment">/* (non-PHPdoc)
* ${see_to_overridden}
*/</template><template autoinsert="true" context="php_delegatecomment_context" deleted="false" description="Comment for delegate methods" enabled="true" id="org.eclipse.php.ui.editor.templates.php.codetemplates.delegatecomment" name="delegatecomment">/**
* ${tags}
* ${see_to_target}
*/</template><template autoinsert="true" context="php_newtype_context" deleted="false" description="Newly created files" enabled="true" id="org.eclipse.php.ui.editor.templates.php.codetemplates.newtype" name="newtype">${filecomment}
${package_declaration}
${typecomment}
${type_declaration}</template><template autoinsert="false" context="php_classbody_context" deleted="false" description="Code in new class type bodies" enabled="true" id="org.eclipse.php.ui.editor.templates.php.codetemplates.classbody" name="classbody">
</template><template autoinsert="false" context="php_interfacebody_context" deleted="false" description="Code in new interface type bodies" enabled="true" id="org.eclipse.php.ui.editor.templates.php.codetemplates.interfacebody" name="interfacebody">
</template><template autoinsert="true" context="php_catchblock_context" deleted="false" description="Code in new catch blocks" enabled="true" id="org.eclipse.php.ui.editor.templates.php.codetemplates.catchblock" name="catchblock">// ${TODO} Auto-generated catch block
${exception_var}.printStackTrace();</template><template autoinsert="true" context="php_methodbody_context" deleted="false" description="Code in created method stubs" enabled="true" id="org.eclipse.php.ui.editor.templates.php.codetemplates.methodbody" name="methodbody">// ${TODO} Auto-generated method stub
${body_statement}</template><template autoinsert="true" context="php_constructorbody_context" deleted="false" description="Code in created constructor stubs" enabled="true" id="org.eclipse.php.ui.editor.templates.php.codetemplates.constructorbody" name="constructorbody">${body_statement}
// ${TODO} Auto-generated constructor stub</template><template autoinsert="true" context="php_getterbody_context" deleted="false" description="Code in created getters" enabled="true" id="org.eclipse.php.ui.editor.templates.php.codetemplates.getterbody" name="getterbody">return ${field};</template><template autoinsert="true" context="php_setterbody_context" deleted="false" description="Code in created setters" enabled="true" id="org.eclipse.php.ui.editor.templates.php.codetemplates.setterbody" name="setterbody">${field} = ${param};</template><template autoinsert="true" context="php_new_file_context" deleted="false" description="Simple php file" enabled="true" id="org.eclipse.php.ui.editor.templates.php.author" name="New simple PHP file"><?php
${cursor}</template><template autoinsert="true" context="php_new_file_context" deleted="false" description="html 4.01 frameset" enabled="true" id="org.eclipse.php.ui.editor.templates.php.html.frameset" name="New PHP file - HTML frameset"><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=${encoding}">
<title>Insert title here</title>
</head>
<frameset>
<frame>
<frame>
<noframes>
<body>
<p>This page uses frames. The current browser you are using does not support frames.</p>
<?php
${cursor}
?>
</body>
</noframes>
</frameset>
</html></template></templates>
格式化程序设置
来自menupoint Formatters的设置(在代码模板下面)在我的Eclipse中设置如下:
标签策略:标签
缩进尺寸:1
标签尺寸:4
包装线的默认indentatino:1
数组初始值设定项的默认缩进:1
内容总结
以上是互联网集市为您收集整理的php – 如何设置Eclipse PDT遵循Zend Framework 2编码约定?全部内容,希望文章能够帮你解决php – 如何设置Eclipse PDT遵循Zend Framework 2编码约定?所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。