您好我的phpcbf有问题。这是我的码头配置:
搬运工-compose.yml
version: "2"
services:
data:
build: docker/application
volumes:
- .:/var/www/html
fpm:
build: docker/php-fpm
volumes_from:
- data
nginx:
build: docker/nginx
ports:
- "80:80"
links:
- fpm
volumes_from:
- data
搬运工/应用/ Dockerfile
FROM debian:jessie
ADD ./ /var/www/html
搬运工/ PHP-FPM / Dockerfile
FROM php:fpm
#Install PHP_CodeSniffer
RUN apt-get update && apt-get install -y wget && apt-get install -y vim && \
wget https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar && \
wget https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar
RUN chmod u+x *.phar
RUN mv phpcbf.phar /usr/local/bin/phpcbf
RUN mv phpcs.phar /usr/local/bin/phpcs
RUN phpcs --config-set default_standard PSR2
RUN apt-get remove -y wget
搬运工/ nginx的/ Dockerfile
FROM nginx:latest
ADD default.conf /etc/nginx/conf.d/
搬运工/ nginx的/ default.conf
server {
listen 80;
root /var/www/html;
location / {
try_files $uri /index.php$is_args$args;
}
location ~ ^/.+\.php(/|$) {
fastcgi_pass fpm:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
}
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
}
phpcs index.php - 测试文件
root@6ad6c7f34641:/var/www/html# phpcs index.php
FILE: /var/www/html/index.php
----------------------------------------------------------------------
FOUND 4 ERRORS AFFECTING 3 LINES
----------------------------------------------------------------------
3 | ERROR | [ ] Each class must be in a namespace of at least one
| | level (a top-level vendor name)
3 | ERROR | [x] Opening brace of a class must be on the line after
| | the definition
6 | ERROR | [x] Opening brace should be on a new line
9 | ERROR | [x] Expected 1 newline at end of file; 0 found
----------------------------------------------------------------------
PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------
Time: 48ms; Memory: 4Mb
自动修复测试,什么都不做。文件没有变化。
root@6ad6c7f34641:/var/www/html# phpcbf index.php
Changing into directory /var/www/html
Processing index.php [PHP => 47 tokens in 9 lines]... DONE in 8ms (3 fixable violations)
=> Fixing file: 0/3 violations remaining [made 3 passes]... DONE in 4ms
sh: 1: patch: not found
Array
(
)
Returned: 127
Time: 103ms; Memory: 4Mb
你能帮助我在哪里,我想念的是什么?谢谢
答案 0 :(得分:1)
问题解决了:错误表明我没有安装补丁命令,PHPCBF使用该命令在一个操作中应用更改。
搬运工/ PHP-FPM / Dockerfile
FROM php:fpm
RUN apt-get update && \
apt-get install -y wget && \
apt-get install -y vim && \
apt-get install -y patch && \
wget https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar && \
wget https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar
RUN chmod u+x *.phar
RUN mv phpcbf.phar /usr/local/bin/phpcbf
RUN mv phpcs.phar /usr/local/bin/phpcs
RUN phpcs --config-set default_standard PSR2
RUN apt-get remove -y wget