https://github.com/secondtruth/synchronizer
Synchronize all kinds of things
https://github.com/secondtruth/synchronizer
php-library synchronizer
Last synced: 4 months ago
JSON representation
Synchronize all kinds of things
- Host: GitHub
- URL: https://github.com/secondtruth/synchronizer
- Owner: secondtruth
- License: mit
- Created: 2014-10-11T15:21:28.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2017-10-27T19:45:40.000Z (over 8 years ago)
- Last Synced: 2025-01-26T12:35:55.893Z (about 1 year ago)
- Topics: php-library, synchronizer
- Language: PHP
- Homepage: http://www.flamecore.org
- Size: 35.2 KB
- Stars: 5
- Watchers: 9
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
FlameCore Synchronizer
======================
[](https://packagist.org/packages/flamecore/synchronizer)
[](https://scrutinizer-ci.com/g/flamecore/synchronizer)
[](https://packagist.org/packages/flamecore/synchronizer)
This library makes it easy to synchronize all kinds of things. It features a beautiful and easy to use API.
Synchronizer was developed as backend for our deployment and testing tool [Seabreeze](https://github.com/FlameCore/Seabreeze).
Implementations
---------------
The Synchronizer library is just an abstract foundation. But concrete implementations are available:
* [FilesSynchronizer](https://github.com/FlameCore/FilesSynchronizer)
* [DatabaseSynchronizer](https://github.com/FlameCore/DatabaseSynchronizer)
Usage
-----
Include the vendor autoloader and use the classes:
```php
namespace Acme\MyApplication;
// To create a Synchronizer:
use FlameCore\Synchronizer\AbstractSynchronizer;
use FlameCore\Synchronizer\SynchronizerSourceInterface;
use FlameCore\Synchronizer\SynchronizerTargetInterface;
// To make your project compatible with Synchronizer:
use FlameCore\Synchronizer\SynchronizerInterface;
require 'vendor/autoload.php';
```
Create your Synchronizer:
```php
class ExampleSynchronizer extends AbstractSynchronizer
{
/**
* @param bool $preserve Preserve obsolete objects
* @return bool Returns whether the synchronization succeeded.
*/
public function synchronize($preserve = true)
{
// Do the sync magic
return true;
}
/**
* @param SynchronizerSourceInterface $source The source
* @return bool Returns whether the synchronizer supports the source.
*/
public function supportsSource(SynchronizerSourceInterface $source)
{
return $source instanceof ExampleSource;
}
/**
* @param SynchronizerTargetInterface $target The target
* @return bool Returns whether the synchronizer supports the target.
*/
public function supportsTarget(SynchronizerTargetInterface $target)
{
return $target instanceof ExampleTarget;
}
}
```
Create your Source and Target:
```php
class ExampleSource implements SynchronizerSourceInterface
{
/**
* @param array $settings The settings
*/
public function __construct(array $settings)
{
// Save settings
}
// Your methods...
}
class ExampleTarget implements SynchronizerTargetInterface
{
/**
* @param array $settings The settings
*/
public function __construct(array $settings)
{
// Save settings
}
// Your methods...
}
```
Make your project compatible with Synchronizer:
```php
class Application
{
protected $synchronizer;
public function setSynchronizer(SynchronizerInterface $synchronizer)
{
$this->synchronizer = $synchronizer;
}
// ...
}
```
Installation
------------
### Install via Composer
[Install Composer](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx) if you don't already have it present on your system:
$ curl -sS https://getcomposer.org/installer | php
To install the library, run the following command and you will get the latest version:
$ php composer.phar require flamecore/synchronizer
Requirements
------------
* You must have at least PHP version 5.4 installed on your system.
Contributing
------------
If you'd like to contribute, please see the [CONTRIBUTING](CONTRIBUTING.md) file first.