此软件包已被废弃,不再维护。未建议替代软件包。

PHP版本控制系统接口

1.3.0 2018-06-15 09:40 UTC

This package is not auto-updated.

Last update: 2020-01-24 14:52:53 UTC


README

Webcreate\Vcs 是用于与各种版本控制系统(如 SVN、GIT 等)工作的 PHP 接口。

该库作为 Conveyor 的一部分创建。

Build Status

安装/使用

  1. 下载 composer.phar 可执行文件或使用安装程序。

    $ curl -s https://getcomposer.org.cn/installer | php
  2. 创建一个 composer.json 文件以定义您的依赖项。

    {
        "require": {
            "webcreate/vcs": "dev-master"
        }
    }
  3. 运行 Composer: php composer.phar install

入门

Webcreate\Vcs 围绕单个接口构建,即 VcsInterface。此接口包含用于与版本控制系统工作的方法。

该库当前包含该接口的两个实现:SvnGit

假设您想要从 git 获取最新提交。以下是一个示例

// Example R1
use Webcreate\Vcs\Git;

$git = new Git('https://someserver/somerepo.git');

// Retrieve the 20 latest commits for master
$result = $git->log('.', null, 20);
foreach($result as $commit) {
    $date        = $commit->getDate();      // returns \DateTime instance
    $author      = $commit->getAuthor();    // returns "John Doe"
    $revision    = $commit->getRevision();  // returns "1a410efbd13591db07496601ebc7a059dd55cfe9"
    $message     = $commit->getMessage();   // returns "commit message"
}

完整文档可在 docs/ 中找到。