Remote Git Library for PHP

Overview

Remote Git Library for PHP

Build Status Coverage Packagist Version Downloads MIT License

This library provides methods to handle git repositories remotely without having to clone the whole repo. It uses the Symfony process component to run the git client.

Usage


use Ausi\RemoteGit\Repository;
use Ausi\RemoteGit\GitObject\File;
use Ausi\RemoteGit\Exception\ConnectionException;

$repo = new Repository('ssh://[email protected]/ausi/remote-git.git');

try {
    $repo->connect();
} catch(ConnectionException $exception) {
    // Unable to connect to the specified server
}

$headCommit = $repo->getBranch('main')->getCommit();

$newTree = $headCommit
    ->getTree()
    ->withFile(
        'example.txt',
        'Example content…',
    )
;

$newCommit = $repo->commitTree($newTree, 'Add example', $headCommit);

$repo->pushCommit($newCommit, 'main');

Installation

To install the library use Composer or download the source files from GitHub.

composer require ausi/remote-git

Speed

Speed comparison of cloning https://gitlab.com/linux-kernel/stable.git and reading the contents of a file:

Command Network Disk Space Time
git clone 3.21 GB 4.6 GB 901 s
git clone --depth 1 207 MB 1.4 GB 77 s
git clone -n --depth 1 207 MB 216 MB 46 s
getBranch(…)->getCommit()->getTree()->getFile(…)->getContents() 2.49 MB 2.57 MB 5.8 s

Naturally, this is strongly dependent on many factors like bandwidth and CPU power and should only give a rough idea of this projects purpose, namely reading or writing small bits of data from or to a remote GIT repository.

You might also like...
Utility that helps you switch git configurations with ease.

git-profile Utility that helps you switch git configurations with ease Preface It is possible that you have multiple git configurations. For example:

Private, self-hosted Composer/Satis repository with unlimited private and open-source packages and support for Git, Mercurial, and Subversion.
Private, self-hosted Composer/Satis repository with unlimited private and open-source packages and support for Git, Mercurial, and Subversion.

Private, self-hosted Composer/Satis repository with unlimited private and open-source packages and support for Git, Mercurial, and Subversion. HTTP API, HTTPs support, webhook handler, scheduled builds, Slack and HipChat integration.

RealMikrotikBackup - Система резервного копирования для оборудования Mikrotik, с возможностью использования функционала Git для контроля версий конфигураций оборудования.
RealMikrotikBackup - Система резервного копирования для оборудования Mikrotik, с возможностью использования функционала Git для контроля версий конфигураций оборудования.

Real Mikrotik Backup System Real Mikrotik Backup - это система централизованного создания и хранения резервных копий оборудования Mikrotik с функцией

Easily manage git hooks in your composer config

composer-git-hooks Manage git hooks easily in your composer configuration. This command line tool makes it easy to implement a consistent project-wide

Text-mode interface for git

Tig: text-mode interface for Git What is Tig? Tig is an ncurses-based text-mode interface for git. It functions mainly as a Git repository browser, bu

CodeFever Community Edition (A Self-hosted Git Services)
CodeFever Community Edition (A Self-hosted Git Services)

CodeFever Community Edition (A Self-hosted Git Services)

A Laravel test build by Incline Start-up Agency. Testing Git and framework functions.

Incognito-Confessions A laravel test build by Incline Start-up Agency. Testing Git and framework functions. Description A laravel starter for future t

Install an execute script of specify quality tools to your git pre-commit hook, and it executes only for changed files

Quality Hook Installer Install an execute script of specify quality tools to your git pre-commit hook, and it executes only for changed files Install

Comments
  • Add option to set private key or private key file

    Add option to set private key or private key file

    ~~Maybe $repo->setSshKey() and $repo->setSshKeyFile() ?~~

    setSshIdentity(string $privateKey): static setSshIdentityPath(string $privateKeyPath): static

    enhancement 
    opened by ausi 1
  • Validate remote URL

    Validate remote URL

    As remote URL we should only accept:

    1. HTTP(S) protocol
    2. SSH Protocol (including scp-like syntax)
    3. GIT protocol

    And throw an exception for all other cases.

    bug 
    opened by ausi 0
  • Add a general ExceptionInterface

    Add a general ExceptionInterface

    Should make things easier if multiple calls are made in the same code:

    try {
        $repo = new Repository('ssh://.....git');
        $branch = $repo->getBranch('main');
    } catch (use Ausi\RemoteGit\ExceptionInterface) {
        // Do not care which one it is, just something with the connection or branch does not fit.
    }
    
    bug 
    opened by Toflar 0
Releases(0.2.2)
Owner
Martin Auswöger
Working at @madeyourday on rocksolidthemes.com
Martin Auswöger
PHP remote closure executor

Jumper Allow you to execute PHP Closure in other distant computer via SSH and without client/server setup. Source computer dependency: PHP >= 5.3 (so

Thibaud Lepretre 45 Aug 11, 2022
This is an experiment to export all RFCs from the PHP wiki into Git, including the change history for each RFC (along with the date and author of each change). This is not meant to replace the wiki.

PHP Requests for Comments (RFCs) About This repository is an experiment to export all RFCs from the PHP wiki into Git, including the change history fo

Ben Ramsey 34 Jun 20, 2022
PhpGit - A Git wrapper for PHP 7.1+

PhpGit PhpGit - A Git wrapper for PHP 7.1+ The project is forked from https://github.com/kzykhys/PHPGit Requirements PHP 7.1+ Git Installation Update

PHPPkg 9 Nov 1, 2022
Very flexible git hook manager for php developers

CaptainHook CaptainHook is an easy to use and very flexible git hook library for php developers. It enables you to configure your git hook actions in

CaptainHook 812 Dec 30, 2022
Rafel is Remote Access Tool Used to Control Victims Using WebPanel With More Advance Features..

Rafel is Remote Access Tool Used to Control Victims Using WebPanel With More Advance Features..

swagkarna 690 Dec 28, 2022
Execute Artisan commands on remote servers

Execute Artisan commands on remote servers This package provides a command to execute Artisan command on a remote server. Here's an example that will

Spatie 238 Dec 29, 2022
Remote or monitor your PocketMine:MP server via browser.

PMRemote Remote or monitor your server via browser. Features Monitor (TPS, Server load, Players count) TODO: Remote (Access server console like RCON,

null 11 Dec 7, 2022
A cross-language remote procedure call(RPC) framework for rapid development of high performance distributed services.

Motan Overview Motan is a cross-language remote procedure call(RPC) framework for rapid development of high performance distributed services. Related

Weibo R&D Open Source Projects 5.8k Dec 20, 2022
Applies a patch from a local or remote file to any package that is part of a given composer project.

Applies a patch from a local or remote file to any package that is part of a given composer project. Patches can be defined both on project and on package level in package config or separate JSON file. Declaration-free mode (using embedded info within patch files) is available as well.

Vaimo 245 Dec 15, 2022
Fsociety RAT, The Open Source C++ Remote Administration Tool (RAT)

Fsociety-RAT It was really fun to make this project! This project have a lot of great features and a very good website control for the bots. The final

Elliot Alderson 11 Nov 30, 2022