digitalkaoz/versioneye-php 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

digitalkaoz/versioneye-php

Composer 安装命令:

composer require digitalkaoz/versioneye-php

包简介

PHP CLI for the VersionEye API

README 文档

README

see https://www.versioneye.com/api/ for API documentation

Build Status Dependency Status Scrutinizer Code Quality Code Coverage SensioLabsInsight Latest Stable Version Total Downloads StyleCI

Installation

There are 2 ways to install it:

  • Download the Phar (recommended)
  • Install from source code

Download the Phar (recommended)

download the latest version from the Releases section or from the cli:

$ wget https://github.com/digitalkaoz/versioneye-php/releases/download/1.0.0/versioneye.phar //or latest stable

Install as global Composer Package

$ composer g require digitalkaoz/versioneye-php

now you can run ~/.composer/vendor/bin/versioneye maybe add this folder to your PATH variable.

Install from source code

first you have to decide which http adapter to use. The library supports all adapters supported by php-http/httpplug

$ composer require digitalkaoz/versioneye-php

##Usage

all API endpoints are implemented, see https://www.versioneye.com/api/ for their detailed docs.

programmatic:

<?php

use Rs\VersionEye\Client;

$api = (new Client())->api('services');     // Rs\VersionEye\Api\Services
$api->ping(); //array

//other implemented APIs
$api = (new Client())->api('github');       // Rs\VersionEye\Api\Github
$api = (new Client())->api('me');           // Rs\VersionEye\Api\Me
$api = (new Client())->api('projects');     // Rs\VersionEye\Api\Projects
$api = (new Client())->api('products');     // Rs\VersionEye\Api\Products
$api = (new Client())->api('sessions');     // Rs\VersionEye\Api\Sessions
$api = (new Client())->api('users');        // Rs\VersionEye\Api\Users

cli:

Here some usage examples.

$ bin/versioneye services:ping
$ bin/versioneye products:search symfony

Or with the phar file.

php versioneye.phar products:search "symfony"
php versioneye.phar products:show "php" "symfony:symfony"

The last command requires that you have setup your API Key correctly.

##Configuration

to store your generated API Token globally you can create a global config file in your home directory:

~/.veye.rc we share the same config file with the ruby cli https://github.com/versioneye/veye

the file would look like:

:api_key: YOUR_API_TOKEN

now you dont have to pass your token on each call!

##CLI Tool

to build a standalone phar, simply execute the following commands.

$ composer require --dev kherge/box
$ vendor/bin/box build
$ php versioneye.phar

Commands:

The Commands are autogenerated by introspecting the API Implementations. Each Public Method is a Command, each Method Parameter will be translated into a InputArgument or InputOption.

 github
  github:delete           remove imported project.
  github:hook             GitHub Hook.
  github:import           imports project file from github.
  github:repos            lists your's github repos.
  github:show             shows the detailed information for the repository.
  github:sync             re-load github data.
 me
  me:comments             shows comments of authorized user.
  me:favorites            shows favorite packages for authorized user.
  me:notifications        shows unread notifications of authorized user.
  me:profile              shows profile of authorized user.
 products
  products:follow         follow your favorite software package.
  products:follow_status  check your following status.
  products:references     shows all references for the given package.
  products:search         search packages.
  products:show           detailed information for specific package.
  products:unfollow       unfollow given software package.
  products:versions       shows all version for the given package.
 projects
  projects:all            shows user`s projects.
  projects:create         upload project file.
  projects:delete         delete given project.
  projects:licenses       get grouped view of licences for dependencies.
  projects:merge          merge two projects together.
  projects:merge_ga       merge two projects together (only for maven projects).
  projects:show           shows the project's information.
  projects:unmerge        unmerge two projects.
  projects:update         update project with new file.
 services
  services:ping           Answers to request with basic pong.
 sessions
  sessions:close          delete current session aka log out.
  sessions:open           creates new sessions.
  sessions:show           returns session info for authorized users.
 users
  users:comments          shows user's comments.
  users:favorites         shows user's favorite packages.
  users:show              shows profile of given user_id.

FAQ

default HTTP-Adapter

since we are relying on php-http we dont ship a default http implementation. (for dev we do)

choose one of these Client Adapters and require it with composer and puli will discover it for you, and we will use it!

implement a new HTTP Adapter

simply implement the Rs\VersionEye\Http\HttpClient Interface:

<?php
class MyHttpClient implements HttpClient
{
    /**
     * @inheritDoc
     */
    public function request($method, $url, array $params = [])
    {
        //implement your own special http handling here
    }
}

and then pass it the the Client:

<?php 

$api = (new Client(new MyHttpClient))->api('users');

writing a new Api

simply implement the Rs\VersionEye\Api\Api Interface:

<?php
namespace Rs\VersionEye\Api;

class Foo implements Api
{
    /**
     * awesome api endpoint
     */
    public function bar($bar, $bazz=1)
    {
        //implement api endpoint
    }
}

the you have to register the Api in the CommandFactory (maybe even that could be autogenerated by searching all implementors of Interface Rs\VersionEye\Api\Api):

<?php 
class CommandFactory
{
    /**
     * generates Commands from all Api Methods
     *
     * @param  array     $classes
     * @return Command[]
     */
    public function generateCommands(array $classes = [])
    {
        $classes = $classes ?: [
            //...
            'Rs\VersionEye\Api\Foo'
        ];
    }
}    

be aware that each public method would be exposed as Command. Mandatory Parameters will be InputArguments, optionals will be a InputOption. The Command description would be taken from the phpdoc!

So the above example will be generated to this Command:

foo:bar --bazz=1 bar      //awesome api endpoint

Writing a new Console Output Formatter

by default the Command tries to find the same API method in the Output Classes (if not it will output the data as simple print_r:

Rs\VersionEye\Api\Github:sync API ----> Rs\VersionEye\Output\Github:sync Output

so for the above Example simply create the following Class:

<?php

namespace Rs\VersionEye\Output;

class Foo
{
    public function bar(OutputInterface $output, $response)
    {
        //output the $response (API Result)
    }
}

thats all.

##Tests

$ composer test

digitalkaoz/versioneye-php 适用场景与选型建议

digitalkaoz/versioneye-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8.69k 次下载、GitHub Stars 达 16, 最近一次更新时间为 2014 年 09 月 11 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 digitalkaoz/versioneye-php 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 16
  • Watchers: 3
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-09-11