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

Running with PHP inside docker #2

Closed
wongjn opened this issue Jan 10, 2019 · 11 comments
Closed

Running with PHP inside docker #2

wongjn opened this issue Jan 10, 2019 · 11 comments

Comments

@wongjn
Copy link
Owner

wongjn commented Jan 10, 2019

I'm having the same problem, but my php is running inside a docker container, I have a /usr/bin/php that looks like this:

#!/bin/bash

docker exec \
    -it \
    -u $(id -u) \
    -w "$PWD" \
    php7 \
    php "$@"

Originally posted by @elvishp2006 in #1 (comment)

Are you running the latest version of the extension?
What is the command to run phpcs with PHP in docker?
Could you provide the settings you are using?

@wongjn #1 (comment)

Yes, I'm using the latest version of the extension.
I got a script on my composer.json:

  "scripts": {
    "lint": "phpcs",
    "lint:fix": "phpcbf"
  }

I just need to run composer lint to run my phpcs.

@elvishp2006 #1 (comment)

@wongjn
Copy link
Owner Author

wongjn commented Jan 10, 2019

So you cannot run phpcs command directly @elvishp2006?

@elvishp2006
Copy link

elvishp2006 commented Jan 10, 2019

If I run the command ./vendor/bin/phpcs (on terminal) it's still work fine, but the extension don't recognize that I have it installed, and I already changed the config to:

"phpSniffer.executablesFolder": "./vendor/bin/phpcs"

@wongjn
Copy link
Owner Author

wongjn commented Jan 10, 2019

Try ./vendor/bin/ exactly instead; the setting is for the folder that both phpcs and phpcbf are both in.

@elvishp2006
Copy link

I tried it now, not worked yet, the extension output a log somewhere?

@wongjn
Copy link
Owner Author

wongjn commented Jan 10, 2019

Yes, open devtools: Help > Toggle Developer Tools

@elvishp2006
Copy link

I'm getting some errors when I save my code:

[Extension Host] the input device is not a TTY
[Extension Host] SyntaxError: Unexpected end of JSON input

@wongjn
Copy link
Owner Author

wongjn commented Jan 10, 2019

I've already solved [Extension Host] SyntaxError: Unexpected end of JSON input in dev but it also means that phpcs command has executed.

Not sure what [Extension Host] the input device is not a TTY is referring to. The extension creates a process and feeds in the file content as stdin - could this be incompatible with Docker?
The error about TTY may also to do with Docker CLI interactions here and here, etc?

@elvishp2006
Copy link

I got my phpcs working with the following:

  • Replaced the -it arg for -i arg
    /usr/bin/php
#!/bin/bash

docker exec \
    -i \
    -u $(id -u) \
    -w "$PWD" \
    php7 \
    php "$@"

But it yet wont work with a custom "phpSniffer.standard": "./phpcs.xml" configuration.
I'm getting the following output on console:

[Extension Host] �[32mE�[0m 1 / 1 (100%)


{"totals":{"errors":1,"warnings":0,"fixable":1},"files":{"STDIN":{"errors":1,"warnings":0,"messages":[{"message":"Expected 1 spaces after opening bracket; 0 found","source":"PEAR.Functions.FunctionCallSignature.SpaceAfterOpenBracket","severity":5,"fixable":true,"type":"ERROR","line":27,"column":16}]}}}

@elvishp2006
Copy link

I discovered what was causing it, was the following lines at my phpcs.xml:

	<arg value="sp"/> <!-- Show sniff and progress -->
	<arg name="colors"/> <!-- Show results with colors -->

There is a way to contorn it with these options?

@elvishp2006
Copy link

The extension is not following these configs:

	<!-- What to scan -->
	<file>.</file>
	<!-- Ignoring Files and Folders:
		https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#ignoring-files-and-folders -->
	<exclude-pattern>api-reference/</exclude-pattern>
	<exclude-pattern>dist/</exclude-pattern>
	<exclude-pattern>node_modules/</exclude-pattern>
	<exclude-pattern>resources/</exclude-pattern>
	<exclude-pattern>vendor/</exclude-pattern>
	<!-- Scrutinizer dependency -->
	<exclude-pattern>wordpress/</exclude-pattern>

It's pointing errors at files inside vendor folder, but it's on exclude-pattern tag.

@wongjn
Copy link
Owner Author

wongjn commented Jan 11, 2019

Thank you. I'm glad we could get to the cause of your issues with this extension. These two points have been moved to separate issues.

@wongjn wongjn closed this as completed Jan 11, 2019
wongjn added a commit that referenced this issue Jan 12, 2019
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

2 participants