Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't locate phpcs on macOS #24

Closed
mignz opened this issue Dec 22, 2016 · 12 comments
Closed

Can't locate phpcs on macOS #24

mignz opened this issue Dec 22, 2016 · 12 comments

Comments

@mignz
Copy link

mignz commented Dec 22, 2016

So I installed VSCode, the phpcs extension and then phpcs using PEAR:

sudo pear install phpcs (does not work without sudo: No releases available for package "pear.php.net/phpcs")

After restarting VSCode I get the message:

phpcs: Unable to locate phpcs. Please add phpcs to your global path or use composer depency manager to install it in your project locally.

which phpcs returns /usr/local/bin/phpcs

Anyone?

@oknixus
Copy link

oknixus commented Jan 6, 2017

@Swift-R me too. I has searched solution with Google since yesterday. But nothing help to resolve this problem. And there is not enough detail in the author's docs

@mignz
Copy link
Author

mignz commented Jan 6, 2017

From what I've read, the issue is with VSCode itself. It doesn't allow extensions to use anything externally anymore.

@gabrielboliveira
Copy link

I was having this same issue. There are two ways I was able to fix:

  1. Install dependency on project-level (refer to this README)
  2. Fix phpcs installation.

What I mean to fix phpcs installation is that for some reason installing with pear (via this other method) was causing an issue to not load on VSCode, and also break on console.

I installed it globally with composer, and also this installation should be the only one to be pointed on your PATH:

$ where phpcs
> /Users/gabrieloliveira/.composer/vendor/bin/phpcs

Before this, I had the pear installation and two of composer linked to phpcs, for some reason still didn't work. After I removed the pear and composer duplicated entry, VSCode worked successfully.

@gwagroves
Copy link

  • Installed plugin
  • Installed phpcs globally using composer
  • Symlinked /Users/[user]/.composer/vendor/bin/phpcs to /usr/local/bin/phpcs
  • Restarted vscode
  • Worked!

@ikappas
Copy link
Owner

ikappas commented Jan 31, 2017

@Swift-R @oknixus @gwagroves @gabrielboliveira Can you please check whether 0.7.0 fixes your issues?

@mignz
Copy link
Author

mignz commented Feb 1, 2017

@ikappas looks like it's working now. I've switched back to Atom in the meanwhile for various reasons and it seems that it's working differently. For example, with the exact same code, Atom reports one line having more than 120 characters and a missing namespace while VSCode reports a missing doc comment for a class and a missing blank line before the tags in a doc comment in a method.

Edit: Never mind, I forgot to set the standard to PSR2. It's still not showing the line too long warning though. Another configuration?

@ikappas
Copy link
Owner

ikappas commented Feb 1, 2017

@Swift-R Are you using global phpcs or project specific with composer?

@mignz
Copy link
Author

mignz commented Feb 1, 2017

Global

@ikappas
Copy link
Owner

ikappas commented Feb 23, 2017

@Swift-R I have switched to using stdIn instead of file parsing and setup utf8 encoding similarly to Atom in v.0.8.0. So I am closing this issue and feel free to test 0.8.0 until it is released!

@ikappas ikappas closed this as completed Feb 23, 2017
@joneslloyd
Copy link

This is also an issue for me by the way. I'm running Version 1.10.2 (1.10.2), and get the error phpcs: Unable to locate phpcs. Please add phpcs to your global path or use composer depency manager to install it in your project locally..

I tried something akin to @gwagroves' fix, so that it now looks like this:
screen shot 2017-03-29 at 16 29 26

But unfortunately I still get this error.

@grEvenX
Copy link

grEvenX commented May 8, 2017

@ikappas I'm having the same problem. How can we help test 0.8.0 before it's oficially released with VSCode?

@Wrenbjor
Copy link

ok it needs to be globally installed via composer for the current versions of VSCode to see it.

Just run:

include_once "/usr/share/pear/PHP/CodeSniffer/autoload.php";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants