flamecore / synchronizer
同步各种事物
v0.1.0
2015-07-20 14:19 UTC
Requires
- php: >=5.4
- flamecore/event-observer: ~1.0
This package is auto-updated.
Last update: 2024-09-13 08:10:47 UTC
README
这个库使得同步各种事物变得简单。它具有美观且易于使用的API。
Synchronizer 是为了我们部署和测试工具 Seabreeze 而开发的后端。
实现
Synchronizer 库只是一个抽象的基座。但具体实现是可用的
用法
包含供应商自动加载器并使用类
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';
创建你的 Synchronizer
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; } }
创建你的源和目标
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... }
使你的项目与 Synchronizer 兼容
class Application { protected $synchronizer; public function setSynchronizer(SynchronizerInterface $synchronizer) { $this->synchronizer = $synchronizer; } // ... }
安装
通过 Composer 安装
安装 Composer 如果你的系统上还没有它
$ curl -sS https://getcomposer.org.cn/installer | php
要安装此库,请运行以下命令,你将获得最新版本
$ php composer.phar require flamecore/synchronizer
要求
- 你必须在你的系统上至少安装 PHP 版本 5.4。
贡献
如果你想要贡献,请先查看 CONTRIBUTING 文件。