Question

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.

Eclipse PHP CodeSinffer configuration

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

Was it helpful?

Solution

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...


(source: zot24.com)

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


(source: zot24.com)

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:


(source: zot24.com)

And done! just enjoy a code clean! :)


(source: zot24.com)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top