如何在Eclipse中为CakePHP设置PHP CodeSniffer + Formartter配置文件?(How to setup PHP CodeSniffer + Formartter pro

编程入门 行业动态 更新时间:2024-10-27 20:34:07
如何在Eclipse中为CakePHP设置PHP CodeSniffer + Formartter配置文件?(How to setup PHP CodeSniffer + Formartter profile for CakePHP in Eclipse?)

我正在尝试使用PHP CodeSniffer + CakePHP Sniffer + Eclipse PHP工具集成

我安装了Eclipse插件,并在Eclipse上下载并安装了CakePHP CodeSniffer代码,如下图所示。

我选择print PHP output to console这样我就可以在尝试分析代码时看到并出错

PHP Fatal error: Uncaught exception 'PHP_CodeSniffer_Exception' with message 'Referenced sniff PSR2.Namespaces.NamespaceDeclaration does not exist' in /home/israel/.eclipse/org.eclipse.platform_4.3.0_1473617060_linux_gtk_x86_64/plugins/org.phpsrc.eclipse.pti.library.pear_1.2.2.R20120127000000/php/library/PEAR/PHP/CodeSniffer.php:814

可能是什么问题呢?

另一方面,我希望能够在CakePHP约定之后格式化我的代码,在那里我可以找到与CakePHP代码约定匹配的fomatter profile 。

谢谢

I'm trying to use PHP CodeSniffer + CakePHP Sniffer + Eclipse PHP Tool Integration

I installed the Eclipse plugin as well as download and install the CakePHP CodeSniffer code on my Eclipse as you can see on the image below.

I select the print PHP output to console so I can see and error when it's trying to analyze my code

PHP Fatal error: Uncaught exception 'PHP_CodeSniffer_Exception' with message 'Referenced sniff PSR2.Namespaces.NamespaceDeclaration does not exist' in /home/israel/.eclipse/org.eclipse.platform_4.3.0_1473617060_linux_gtk_x86_64/plugins/org.phpsrc.eclipse.pti.library.pear_1.2.2.R20120127000000/php/library/PEAR/PHP/CodeSniffer.php:814

What could be the problem?

In the other hand I want to be able to format my code following the CakePHP Conventions where can I found a fomatter profile that match with the CakePHP code conventions.

Thanks

最满意答案

我有几个问题试图安装CodeSniffer并使其正确运行Eclipse。

这是我为使其正常运行所遵循的步骤,您将在本文中找到有关如何配置, 如何Eclipse + CodeSniffer + CakePHP Sniff的详细说明。


转到Eclipse上的首选项菜单并导航到...

PHP -> PHP Executables -> Add...

http://blog.zot24.com/content/images/2014/Feb/configuring_php_homebrew_in_eclipse.png

一旦我们在Eclipse上配置了PHP,我们就必须设置PEAR去...

PHP Tools -> Library -> PEAR -> New...

并选择使用homebrew程序安装php55的path ,您可以运行此命令来了解php55的路径

brew --prefix php55

然后在该命令的末尾添加

.../lib/PHP

http://blog.zot24.com/content/images/2014/Feb/codesniffer_cakephp_eclipse_1.png

最后一步是选择我们刚刚配置的PEAR路径作为PHP CodeSniffer使用的默认库,如下图所示:

http://blog.zot24.com/content/images/2014/Feb/codesniffer_cakephp_eclipse_2.png

并做了! 只是享受清洁代码! :)

http://blog.zot24.com/content/images/2014/Feb/codesniffer_cakephp_eclipse_3.png

I had several problem trying to install CodeSniffer and make it run with Eclipse properly.

That was the steps I followed to made it run properly, you will find on this post detailed instructions about how to configure, How to Eclipse + CodeSniffer + CakePHP Sniff.


Go to the preferences menu on Eclipse and navigate to...

PHP -> PHP Executables -> Add...

http://blog.zot24.com/content/images/2014/Feb/configuring_php_homebrew_in_eclipse.png

Once we have PHP configured on our Eclipse we have to setup PEAR go to...

PHP Tools -> Library -> PEAR -> New...

And select the path where php55 was installed using homebrew, you can run this command to know the path of php55

brew --prefix php55

Then just add at the end of that command

.../lib/PHP

http://blog.zot24.com/content/images/2014/Feb/codesniffer_cakephp_eclipse_1.png

And the last step is select our just configured PEAR path a the default library used by our PHP CodeSniffer, as you can see on the imagen below:

http://blog.zot24.com/content/images/2014/Feb/codesniffer_cakephp_eclipse_2.png

And done! just enjoy a code clean! :)

http://blog.zot24.com/content/images/2014/Feb/codesniffer_cakephp_eclipse_3.png

更多推荐

本文发布于:2023-07-22 00:59:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1215494.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:配置文件   中为   如何在   CakePHP   PHP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!