mlukman / gitsync
GitSync allows system admin to sync contents of a directory with a specific branch of a Git repository.
Installs: 28
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Type:project
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-11-07 15:26:08 UTC
README
Introduction
GitSync is a PHP tool that will sync any directory on your server with a Git repository. It provides GUI for server admins to synchronize a directory with any commit (i.e. revision) of the source code with a click of a button.
Installation
Pre-requisites
- PHP 5.4 and above running on Apache2.
- Git already installed and added to the PATH on your machine.
- Composer already installed and added to the PATH on your machine.
Using Git
Execute the following commands:
mkdir /path/to/GitSync
cd /path/to/GitSync
git clone https://github.com/MLukman/GitSync .
composer install
Then, customize index.php
to match your directories. Refer the section on 'Customization' below.
Using composer
Execute the following commands:
mkdir /path/to/GitSync
cd /path/to/GitSync
composer require mlukman/gitsync
Then, either copy index.php
from folder vendor/mlukman/gitsync/
or create your own file using the following section on 'Customization'.
Customization
Basic Setup
At the minimum, index.php
is the only file that you need to modify in order to customize your installation of GitSync.
First, the file must have the following file at or near the beginning of the file:
require __DIR__.'/vendor/autoload.php';
Next, you need to instantiate a \GitSync\Config
object:
$config = new \GitSync\Config();
To add a directory to the list of directories that GitSync manages, instantiate a \GitSync\Context
object and add it to the $config
object using addContext()
method:
$context01 = new \GitSync\Context('\path\to\directory', 'http://remote.url/repo.git', 'branchname');
$config->addContext($context01);
Repeat for as many directories as you want.
Finally, instantiate a \GitSync\Application
object while passing the $config
object and let it run.
$app = new \GitSync\Application($config);
$app->run();
That's the basic working setup.
Secure Setup
Of course, GitSync without security is like begging to be hacked, so GitSync utilizes Securilex security module. Refer Securilex's README for detailed usage of the module.
To enable secure mode, you just have to call \GitSync\Application::activateSecurity
method, passing an instance of \Securilex\DriverInterface
to the method.
\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
Using LdapSecurityProvider is similar but you need to provide the host, port and distinguised name (DN) string:
// 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);