Download the PHP package fedorlabs/sync-forge without Composer

On this page you can find all versions of the php package fedorlabs/sync-forge. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package sync-forge

SyncForge

CI

SyncForge is a Symfony/Doctrine library for reconciling external datasets (array/iterable) with an entity table using batched DBAL operations.

Status: Early stable release (v0.3.1).

Typical use case: you get data from an API, CSV, ERP or marketplace feed, and need to keep a DB table in sync - upsert changed rows, delete rows that disappeared from the source, skip what hasn't changed - all without loading 100k entities into Doctrine's UnitOfWork.

With the Doctrine ORM metadata provider, keys and source row keys are mapped entity field names, not database column names. For example, use externalId for an entity property mapped to external_id. Every row must contain every configured key field. Ensure those fields uniquely identify a row in the table; PostgreSQL ON CONFLICT also requires a matching unique constraint or index.

Features

Requirements

Installation

Quick Start

Symfony Integration

Register the bundle in config/bundles.php:

The bundle autowires SyncForge using doctrine.orm.entity_manager and doctrine.dbal.default_connection.

Examples

Paginated API source

Passing a generator lets SyncForge stream pages without loading everything into memory first:

Composite key

Scope: replace one supplier's data

scope() limits the sync to rows matching the given field values. Existing rows are looked up and deleted only inside the scope, and the scope values are filled into inserted rows that do not carry them. A source row with a different value for a scope field is rejected.

Scope fields must be mapped and must be part of the sync key, values must be scalar or null, and the existing rows provider must implement ScopedExistingRowsProviderInterface (the DBAL one does); otherwise the run fails instead of reading or deleting rows outside the scope.

The scope fields have to be in the key because rows are looked up inside the scope only: with a key such as sku alone, a row of another scope with the same sku is not found, planned as an insert, and the upsert would then take that row over. The run is rejected before anything is written.

Timestamps and constructor defaults

SyncForge writes through DBAL and does not call entity setters, so values that a constructor or a setter used to set have to be declared:

Chaining child records

returnInserted() fills SyncResult::$insertedKeys with the key fields and identifier fields of every inserted row, read back from the database after each chunk, so generated ids can be used to insert child rows. In a dry run only the key fields of the planned inserts are returned. The list is kept in memory for the whole run, so enable it only when the number of inserted rows is manageable. returnUpdated() fills SyncResult::$updatedKeys the same way (key and identifier fields of rows that changed, with the identifiers as they are in the database, also in a dry run), and returnDeleted() fills SyncResult::$deletedKeys with the key fields of rows removed by deleteMissing. Use them to reindex search or invalidate caches for exactly the changed rows.

Dry-run before delete

Only enable deletion when the source is a complete snapshot of the entire table. Start with a dry run and inspect deleted, warnings, and errors. A dry run does not guarantee that a later run is safe: the source or database may change.

Error handling

Sync Result

run() returns SyncResult:

Property Type Description
inserted int planned inserts executed, or planned inserts in dry-run
updated int planned updates executed, or planned updates in dry-run
deleted int planned deletes executed, or planned deletes in dry-run
unchanged int rows with no diff
processedRows int total incoming rows
chunkCount int number of chunks processed
dryRun bool whether writes were skipped
warnings list<string> e.g. duplicate key warnings
errors list<ErrorEntry> typed errors when continueOnError is on
isSuccess() bool true when errors is empty

Limitations

Performance Benchmark

The benchmark runs against dedicated PostgreSQL and MariaDB containers and reports runtime, process memory and operation counters. Results depend on the environment; measure with a representative dataset before capacity planning.

It drops and recreates products_bench in the configured benchmark databases. The bench:down command removes Compose volumes. Use only disposable databases and verify the Docker Compose project and volume configuration first.

To run it:

Integration Tests

External database tests drop and recreate a table named products. Use dedicated test databases, never a database containing application data. Missing DSNs cause the corresponding tests to be skipped.

Development


All versions of sync-forge with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
doctrine/dbal Version ^4.2
symfony/config Version ^6.4 || ^7.0 || ^8.1
symfony/dependency-injection Version ^6.4 || ^7.0 || ^8.1
symfony/http-kernel Version ^6.4 || ^7.0 || ^8.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package fedorlabs/sync-forge contains the following files

Loading the files please wait ...