mlukman / gitsync
GitSync 允许系统管理员同步目录与 Git 仓库的特定分支的内容。
Requires
- php: >=5.6.0
- cypresslab/gitelephant: 1.*
- mlukman/securilex: 1.*
- monolog/monolog: 1.*
- silex/silex: ~1.3
- symfony/serializer: ^3.0
- symfony/twig-bridge: ^3.0
This package is auto-updated.
Last update: 2024-09-07 15:02:36 UTC
README
简介
GitSync 是一个 PHP 工具,可以同步服务器上的任何目录与 Git 仓库。它为服务器管理员提供了一个图形界面,只需点击按钮即可同步目录与源代码的任何提交(即修订)。
安装
先决条件
- Apache2 上运行 PHP 5.4 及以上版本。
- Git 已安装并添加到您的机器的 PATH。
- 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);