shadiakiki1986/flysystem-git

本包最新版本(0.0.8)没有可用的许可信息。

git仓库的Flysystem适配器

0.0.8 2016-11-24 06:53 UTC

This package is auto-updated.

Last update: 2024-09-27 02:36:40 UTC


README

Build Status

flysystem提供的适配器,通过node-git-rest-api服务器和git-rest-api-client-php与任何git仓库进行交互

使用方法

packagist安装

composer install shadiakiki1986/flysystem-git

启动一个node-git-rest-api服务器

docker run -p 8081:8081 -it shadiakiki1986/docker-node-git-rest-api

示例

<?php
require_once 'vendor/autoload.php';

use League\Flysystem\Filesystem;

// prepare adapter
// http://github.com/shadiakiki1986/git-rest-api-client-php
$git = new \GitRestApi\Client('https://:8081');

// for read-write, include the correct username/password below
$remote = 'https://someone:somepass@github.com/shadiakiki1986/git-data-repo-testDataRepo';
$repo = $git->cloneRemote($remote,1); // passing 1 for clone --depth to save some time for repositories with a long history

// for writing to the remote repo, i.e. if "push" variable below is true, need to set username and email
// not needed if read-only usage
$repo->putConfig('user.name','phpunit test flysystem-git');
$repo->putConfig('user.email','shadiakiki1986@gmail.com');

// initialize filesystem for further usage
$push = false; // set to false to make read/write possible without pushing to remote. Set to true to push to remote
$pull = true; // set to true to skip pulling from the remote repository at each transaction in order to save on time
$adapter = new \shadiakiki1986\Flysystem\Git($repo,$push,$pull);
$filesystem = new Filesystem($adapter);

// read a file
$contents = $filesystem->read('bla');

// if username/password above are correct, can also update the file
$filesystem->update('bla','some new content');

// write to a new file
$filesystem->write('new folder/new file','content of file');