mlukman/gitsync

GitSync 允许系统管理员同步目录与 Git 仓库的特定分支的内容。

安装: 27

依赖项: 0

建议者: 0

安全: 0

星星: 1

关注者: 1

分支: 0

开放问题: 0

类型:项目

1.1.4 2018-03-13 03:45 UTC

README

GitSync logo

Packagist Version Packagist License GitHub issues

简介

GitSync 是一个 PHP 工具,可以同步服务器上的任何目录与 Git 仓库。它为服务器管理员提供了一个图形界面,只需点击按钮即可同步目录与源代码的任何提交(即修订)。

安装

先决条件

  1. Apache2 上运行 PHP 5.4 及以上版本。
  2. Git 已安装并添加到您的机器的 PATH。
  3. Composer 已安装并添加到您的机器的 PATH。

使用 Git

执行以下命令

mkdir /path/to/GitSync
cd /path/to/GitSync
git clone https://github.com/MLukman/GitSync .
composer install

然后,根据您的目录定制 index.php。请参考下面的“定制”部分。

使用 composer

执行以下命令

mkdir /path/to/GitSync
cd /path/to/GitSync
composer require mlukman/gitsync

然后,要么从 vendor/mlukman/gitsync/ 文件夹复制 index.php,要么使用下面的“定制”部分创建自己的文件。

定制

基本设置

至少,您需要修改 index.php 文件来定制 GitSync 的安装。

首先,文件必须包含以下内容,位于文件的开头或附近

require __DIR__.'/vendor/autoload.php';

接下来,您需要实例化一个 \GitSync\Config 对象

$config = new \GitSync\Config();

要将目录添加到 GitSync 管理的目录列表中,实例化一个 \GitSync\Context 对象,并使用 addContext() 方法将其添加到 $config 对象

$context01 = new \GitSync\Context('\path\to\directory', 'http://remote.url/repo.git', 'branchname');
$config->addContext($context01);

根据需要重复此操作。

最后,实例化一个 \GitSync\Application 对象,同时传递 $config 对象,并让其运行。

$app = new \GitSync\Application($config);
$app->run();

这就是基本的工作设置。

安全设置

当然,没有安全的 GitSync 就像是向黑客发出求救信号,所以 GitSync 使用 Securilex 安全模块。请参阅 Securilex 的 README 了解模块的详细用法。

要启用安全模式,您只需调用 \GitSync\Application::activateSecurity 方法,并将 \Securilex\DriverInterface 实例传递给该方法。

\Securilex\Driver\SimpleDriver

// create a new driver
$driver = new \Securilex\Driver\SimpleDriver();

// user with ROLE_ADMIN implicitly gets access to all contexts
$driver->addUser('admin', 'admin', array('ROLE_ADMIN'));

// user with ROLE_USER needs to be given explicit access to specific contexts
$driver->addUser('user01', 'user01', array('ROLE_USER'));

// ditto
$driver->addUser('user02', 'user02', array('ROLE_USER'));

// Add user01 & user02 to the list of user id allowed access
$context->addAllowedUid('user01')->addAllowedUid('user02');

// Activate security using the driver
$app->activateSecurity($driver);

\Securilex\Driver\LdapDriver

使用 LdapSecurityProvider 类似,但您需要提供主机、端口和区分名称(DN)字符串

// create a new driver
$driver = new \Securilex\Driver\LdapDriver("ldap.mycompany.com", 389, "uid={username},ou=People,o=MyCompany");

// No password needed when adding user to LdapSecurityProvider 
$driver->addUser('JohnDoe', array('ROLE_ADMIN'));

// Activate security using the driver
$app->activateSecurity($driver);

由以下提供支持

Silex logo

GitElephant logo