synchronizer
1.0.0
Эта библиотека позволяет легко синхронизировать самые разные вещи. Он имеет красивый и простой в использовании API.
synchronizer был разработан в качестве серверной части для нашего инструмента развертывания и тестирования Seabreeze.
Библиотека synchronizer — это всего лишь абстрактная основа. Но доступны конкретные реализации:
Включите автозагрузчик поставщика и используйте классы:
namespace Acme MyApplication ;
// To create a synchronizer :
use FlameCore synchronizer Abstract synchronizer ;
use FlameCore synchronizer synchronizer SourceInterface ;
use FlameCore synchronizer synchronizer TargetInterface ;
// To make your project compatible with synchronizer :
use FlameCore synchronizer synchronizer Interface ;
require ' vendor/autoload.php ' ;Создайте свой synchronizer :
class Example synchronizer extends Abstract synchronizer
{
/**
* @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 synchronizer SourceInterface $source The source
* @return bool Returns whether the synchronizer supports the source.
*/
public function supportsSource ( synchronizer SourceInterface $ source )
{
return $ source instanceof ExampleSource;
}
/**
* @param synchronizer TargetInterface $target The target
* @return bool Returns whether the synchronizer supports the target.
*/
public function supportsTarget ( synchronizer TargetInterface $ target )
{
return $ target instanceof ExampleTarget;
}
}Создайте свой источник и цель:
class ExampleSource implements synchronizer SourceInterface
{
/**
* @param array $settings The settings
*/
public function __construct ( array $ settings )
{
// Save settings
}
// Your methods...
}
class ExampleTarget implements synchronizer TargetInterface
{
/**
* @param array $settings The settings
*/
public function __construct ( array $ settings )
{
// Save settings
}
// Your methods...
}Сделайте свой проект совместимым с synchronizer :
class Application
{
protected $ synchronizer ;
public function set synchronizer ( synchronizer Interface $ synchronizer )
{
$ this -> synchronizer = $ synchronizer ;
}
// ...
}Установите Composer, если он еще не установлен в вашей системе:
$ curl -sS https://getcomposer.org/installer | php
Чтобы установить библиотеку, выполните следующую команду, и вы получите последнюю версию:
$ php composer.phar require flamecore/ synchronizer
Если вы хотите внести свой вклад, сначала просмотрите файл CONTRIBUTING.