Fixer PHP CS được duy trì trên GitHub tại //github.com/friendsofphp/php-cs-fixer Báo cáo và ý tưởng về các tính năng mới được chào đón ở đó. Công cụ Fix Trình sửa lỗi mã hóa PHP [Fixer CS Fixer] sửa mã của bạn để tuân theo các tiêu chuẩn; Cho dù bạn muốn làm theo các tiêu chuẩn mã hóa PHP như được định nghĩa trong PSR-1, PSR-2, v.v., hoặc các tiêu chuẩn cộng đồng khác như Symfony One. Bạn cũng có thể xác định kiểu [nhóm] của bạn thông qua cấu hình.also define your [teams] style through configuration.also define your [teams] style through configuration.Laravel PHP CS Fixer
Gói này giúp dễ dàng sử dụng Fixer Php CS để duy trì mã Laravel của bạn bằng cách cung cấp quyền truy cập vào nó thông qua các công cụ mà bạn đã quen thuộc. Một lệnh Artisan để sửa mã và quản lý cấu hình theo cách bạn thực hiện tất cả các gói Laravel khác mà bạn sử dụng.
Các tính năng của gói này
- Chạy các lệnh Fixer PHP-CS thông qua Laravel Artisan CLI.
- Cấu hình kiểu mã Laravel được sử dụng theo mặc định.
- Không cần phải học một công cụ mới.
Phiên bản và khả năng tương thích
Lưu ý: Tài liệu này được viết cho Laravel 5.5. This documentation was written for Laravel 5.5. This documentation was written for Laravel 5.5.
- Phiên bản PHP: " ^7.1.3 || ^8.0"
- Laravel/lum: "^5.4 |^6.0 |^7.0 |^8.0"
- Php-cs-fixer: "^3.0.0"
Cài đặt
composer require stechstudio/laravel-php-cs-fixer
Cấu hình
Cấu hình quy tắc mặc định nằm trong Fixer.php và được dự định để phù hợp với các quy tắc được sử dụng bởi Laravel Shift.
Nếu bạn muốn tự sửa đổi điều này, chỉ cần sử dụng Artisan no___trans___pre___4 và nó sẽ đặt cấu hình mặc định vào 'config/fixer.php'. Kiểm tra php-cs-fixer/readme để biết các quy tắc hợp lệ. PHP-CS-Fixer/README for valid rules.
PHP-CS-Fixer/README for valid rules.
Cách sử dụng
Sửa mã của bạn
Sửa mã của bạn với các tiêu chuẩn mã hóa Laravel.
Syntax:
$ php artisan fixer:fix [options]
Example:
Usage:
fixer:fix [options] [--] [...]
Arguments:
path The path. Can be a list of space separated paths
Options:
--path-mode=PATH-MODE Specify path mode [can be override or intersection]. [default: "override"]
--allow-risky=ALLOW-RISKY Are risky fixers allowed [can be yes or no].
--config=CONFIG The path to a .php-cs-fixer.php file.
--dry-run Only shows which files would have been modified.
--rules=RULES The rules.
--using-cache=USING-CACHE Does cache should be used [can be yes or no].
--cache-file=CACHE-FILE The path to the cache file.
--diff Also produce diff for each file.
--format=FORMAT To output results in other formats.
--stop-on-violation Stop execution on first violation.
--show-progress=SHOW-PROGRESS Type of progress indicator [none, dots].
-h, --help Display help for the given command. When no command is given display help for the list command
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
--env[=ENV] The environment the command should run under
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug