PHPackages                             vespolina/syncer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. vespolina/syncer

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

vespolina/syncer
================

Vespolina synchronization library to sync entities with remote services

3172[3 issues](https://github.com/vespolina/syncer/issues)PHP

Since Nov 25Pushed 12y ago1 watchersCompare

[ Source](https://github.com/vespolina/syncer)[ Packagist](https://packagist.org/packages/vespolina/syncer)[ RSS](/packages/vespolina-syncer/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Vespolina Syncer Library
========================

[](#vespolina-syncer-library)

[![Build Status](https://camo.githubusercontent.com/ee9b0964cf4801bc020f563150e21d38bcc3df785393e44c9005b878fcf98e68/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f766573706f6c696e612f73796e6365722e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/vespolina/syncer)

This library is part of the [Vespolina Ecommerce Framework](http://vespolina.org/)and licensed under the [MIT License](LICENSE).

Description
-----------

[](#description)

This library handles synchronisation of entities (eg. products, orders, invoices, content) from a remote service into a local application. It furthers allows dependent entities to be synchronized as well. For instance in order to retrieve an invoice you would also need remote customer information and referenced products.

Partial retrieved entities and dependent entities can be persisted to a gateway allowing the process to be halted at any time and picked up later.

Requirements
------------

[](#requirements)

None ;-)

Documentation
-------------

[](#documentation)

Example usage

```
// Create a new manager capable of persisting data in memory and default configuration
$syncManager = new SyncManager(new SyncMemoryGateway(), new EventDispatcher(), $this->logger);

// Instantiate your own service adapter, for example for the ZOHO api
$zohoServiceAdapter = new ZohoServiceAdapter($this->config, $this->logger);,

// Register the service adapter. The service adapter will indicate it supports the 'invoice' entity
$syncManager->addServiceAdapter($zohoServiceAdapter);

// Register a local object manager to retrieve local customer instances from the database
$syncManager->addLocalEntityRetriever('customer', $customerManager, 'findById');

// Start synchronisation for entity name 'invoice'
$syncManager->execute(array('invoice'));
```

The service adapter needs to implement abstract methods *fetchEntities* , *fetchEntity* and *transformEntityData*.

*fetchEntities* downloads the entities from a remote service and creates for each remote entity an EntityData instance. This instance contains the name of the entity (eg. 'invoice'), the remote identification (eg. zoho id '234324') and raw entity information (eg. xml or json data).

When dependencies are detected by the sync manager it will first check if the dependency already exists in the local application. If this isn't the case the configured service adapter for the dependent remote entity will be used to retrieve and create the entity local. For instance the zoho invoice entity requires the zoho customer entity as well. Therefore the remote customer information needs to be retrieved first and a local customer instance needs to be created and persisted. Only then the invoice can be created.

The system can directly resolve dependencies when detected or first store the partial data of the main entity (eg. 'invoice').

Resolve dependencies immediately (default):

1. For each remote invoice
2. Register partial invoice data in EntityData,
3. Resolve dependent remote entity 'customer' 12313
4. Resolve dependent remote entity 'product' 222 and 'product' 333
5. When local 'customer' and 'product entities have been created, use that to create the invoice entity
6. End for each remote invoice

Delay resolving dependencies (`delay_dependency_processing` is set to true):

1. For each remote invoice
2. Register partial invoice data in EntityData,
3. End for each remote invoice
4. For each unresolved dependency
5. Resolve dependency
6. End for each unresolved dependency
7. Retrieve partial entity date invoices
8. transform into a real invoice
9. When local 'customer' and 'product' entities have been created, use that to create the invoice entity

Having all dependencies resolved the requested entity (eg 'invoice') is created using the *transformEntityData* method of the service adapter.

You can also provide configuration options to the manager to define your synchronisation:

```
$yamlParser = new Parser();
$config = $yamlParser->parse(file_get_contents(__DIR__ . '/config.yml'));
$this->manager = new SyncManager($gateway, $dispatcher, $logger, $config['syncer']);
```

And your sync configuration file could look like:

```
syncer:
    direction: download
    use_id_mapping: true
    delay_dependency_processing: false
    entities:
        customer:
            strategy:  changed_at
        product:
            strategy: incremental_id
        invoice:
            strategy: incremental_id
            dependencies:
                - customer
                - product
    remotes:
        demo_system_1:
            adapter: Vespolina\Sync\Adapter\RemoteAdapter
```

+If you are using Symfony you can check the [Syncer Bundle](https://github.com/cordoval/CordovalSyncerBundle).

For the install guide and reference, see:

- [Syncer documentation](http://docs.vespolina.org/components/syncer.html)

Contributing
------------

[](#contributing)

Pull requests are welcome. Please see our [CONTRIBUTING](http://vespolina.org/contributing/guide)guide.

Unit and/or functional tests exist for this library. See the \[Testing documentation\](() for a guide to running the tests.

Thanks to [everyone who has contributed](https://github.com/vespolina/syncer/contributors) already.

###  Health Score

17

↓

LowBetter than 6% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 64.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/bd5a2c6deedf2f52379d21fa55c9f5c6d0999b0ac1ca2ca2f33293e229107bfe?d=identicon)[iampersistent](/maintainers/iampersistent)

![](https://www.gravatar.com/avatar/c36892b0d7889179d04c8c39e6fb84b57ff16656d34737e8f6350cb0ed01ea28?d=identicon)[inspiran](/maintainers/inspiran)

---

Top Contributors

[![cordoval](https://avatars.githubusercontent.com/u/328359?v=4)](https://github.com/cordoval "cordoval (34 commits)")[![inspiran](https://avatars.githubusercontent.com/u/372447?v=4)](https://github.com/inspiran "inspiran (19 commits)")

### Embed Badge

![Health badge](/badges/vespolina-syncer/health.svg)

```
[![Health](https://phpackages.com/badges/vespolina-syncer/health.svg)](https://phpackages.com/packages/vespolina-syncer)
```

###  Alternatives

[scws/pscws4

PSCWS 是英文 PHP Simple Chinese Words Segmentation 的头字母缩写，它是 SCWS 项目的前身。

1213.2k1](/packages/scws-pscws4)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
