定制 spaze/phpcs-phar 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

spaze/phpcs-phar

Composer 安装命令:

composer require --dev spaze/phpcs-phar

包简介

PHP_CodeSniffer phar releases, automated and always up-to-date

关键字:

README 文档

README

Create a phar release PHP Tests

This repo contains phar releases of PHPCSStandards/PHP_CodeSniffer.

The files are downloaded from the PHP_CodeSniffer release pages, and if changed, they're commited and a release is created with the same version number as the upstream release.

The whole thing is powered by a GitHub Actions workflow.

I have created this for my personal usage to overcome the performance issues of the 9P filesystem as used by WSL2. The PHPCSStandards organization is also planning to create a Composer phar release so this repository will cease to exist one day, either when the official Composer phar is released, or when the 9P performace is sufficient, or when I retire. Consider yourself warned.

Installation

Install with Composer:

composer require --dev spaze/phpcs-phar

Installing coding standards

The phar releases in this repository do not work with the PHP_CodeSniffer Standards Composer Installer Plugin (the dealerdirect/phpcodesniffer-composer-installer package). Be warned that this package even replaces the installer plugin in its composer.json.

There are several reasons for that:

  1. The installer plugin looks for a different installed package, squizlabs/php_codesniffer to add more standards to
  2. The plugin creates a configuration file with a relative path to the standard being installed, so the code sniffer then expects the standard to be present inside the phar file, which is not the case

However, there are multiple different ways to install a standard. Let's say you want to add slevomat/coding-standard, you can:

Auto-install the available standards

If the CodeSniffer.conf file doesn't exist, this package will find and auto-install all available coding standards on each execution. The altered configuration is not persisted, no config file will be created, because it would be removed on each package update anyway. This is the recommended option emulating the Standards Composer Installer Plugin to a certain point. The performance is comparable to using the installer plugin as only Composer metadata are used to find the installed coding standards.

Modify the config file

  1. In your project, run
    vendor/bin/phpcs --config-set installed_paths ../../slevomat/coding-standard
    
  2. Locate the CodeSniffer.conf file in your vendor/spaze/phpcs-phar directory
  3. Edit the path to the installed standard and make it an absolute path, for example change
    'installed_paths' => '../../slevomat/coding-standard'
    to
    'installed_paths' => __DIR__ . '/../../slevomat/coding-standard'

Please be aware that the CodeSniffer.conf file will be removed on each package update.

Install the standard using an absolute path

In your project, run

vendor/bin/phpcs --config-set installed_paths $(realpath vendor/slevomat/coding-standard)

or use any absolute path for the installed_paths value.

Please be aware that the CodeSniffer.conf file will be removed on each package update.

spaze/phpcs-phar 适用场景与选型建议

spaze/phpcs-phar 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.97k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 01 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「dev」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 spaze/phpcs-phar 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 spaze/phpcs-phar 我们能提供哪些服务?
定制开发 / 二次开发

基于 spaze/phpcs-phar 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 5.97k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2024-01-26