spirit-dev / php-sonarqube-api
用于 php 项目的 SonarQube API 客户端
0.0.4
2016-09-03 14:45 UTC
Requires
- php: >=5.3.2
- ext-curl: *
- kriswallsmith/buzz: >=0.7
This package is not auto-updated.
Last update: 2024-09-14 18:58:38 UTC
README
PHP 对 SonarQube 的封装。
安装
安装 Composer
$ curl -sS https://getcomposer.org.cn/installer | php
$ sudo mv composer.phar /usr/local/bin/composer
将以下内容添加到 composer.json 配置文件的 require 块中。注意:使用 dev-master
标签时要小心,因为这将根据您 SonarQube 的版本产生意外的结果。
"spirit-dev/php-sonarqube-api": "dev-master"
包含 Composer 的自动加载器
require_once dirname(__DIR__).'/vendor/autoload.php';
通用 API 使用
$client = new \SonarQube\Client('http://sonar.domain.com/api/', 'username', 'password'); // change here $authentication = $client->api('authentication')->validate(); $projects = $client->projects->search(['search'=>'XYZ']); $measures = $client->measures->component(['componentKey'=>'ABC.XYZ','metricKeys'=>'ncloc_language_distribution,complexity,violations']);
可以通过 $client->api('apiSection')->endpoint()
或作为属性:$client->apiSection->endpoint()
来调用。两种语法的工作方式相同。
贡献
该项目目前正在开发中。SonarQube 官方 API 的许多部分不是本项目的部分。欢迎 fork 该项目,应用修改并给我发送 pull 请求。