PHPackages                             phpbook/etl - 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. phpbook/etl

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

phpbook/etl
===========

PHP ETL Library

1.0.9(5y ago)117MITPHPPHP &gt;=7.1.0

Since Jan 20Pushed 5y ago1 watchersCompare

[ Source](https://github.com/phpbook-sources/etl)[ Packagist](https://packagist.org/packages/phpbook/etl)[ Docs](https://github.com/phpbook-sources/etl)[ RSS](/packages/phpbook-etl/feed)WikiDiscussions master Synced 5d ago

READMEChangelog (10)Dependencies (2)Versions (11)Used By (0)

- [About ETL](#about-etl)
- [Composer Install](#composer-install)
- [ETL Mapper Example](#etl-mapper-example)
- [ETL Schema Example](#etl-schema-example)
- [ETL Loader Example](#etl-loader-example)
- [ETL Run Example](#etl-run-example)

### About ETL

[](#about-etl)

- A lightweight ETL PHP library.
- The local/external connections and entities are in the PHPBOOK/DATABASE. Require PHPBOOK/DATABASE.
- The storage is in the PHPBOOK/STORAGE to store temporary informations. Require PHPBOOK/STORAGE.
- Provide a routine to exchange data between local and external databases with inserts, updates and deletes.

### Composer Install

[](#composer-install)

```
composer require phpbook/etl

```

### ETL Mapper Example

[](#etl-mapper-example)

```
    class Customer extends \PHPBook\ETL\Mapper {

        public function getValuesHashByExternalEntity($externalEntity) {

            //return a hash of data values based on the external entity.
            //equals local and external entity values must return same hash
            //do not use id in this hash
            return md5($externalEntity->name . $externalEntity->description);
        }

        public function getNewExternalEntity($localEntity) {

            //new external entity. Do not need pass the external value to the external entity
            $externalEntity = new \Customer\ETL\ERP\Entity\Customer();
            $externalEntity->name = $localEntity->name;
            $externalEntity->description = $localEntity->description;

            return $externalEntity;

        }

        public function getUpdatedExternalEntity($externalEntity, $localEntity) {

            //edit external entity. Do not need pass the external value to the external entity
            $externalEntity->name = $localEntity->name;
            $externalEntity->description = $localEntity->description;

            return $externalEntity;
        }

        public function getValuesHashByLocalEntity($localEntity) {

            //return a hash of data values based on the local entity.
            //equals local and external entity values must return same hash
            //do not use id, integration id/hash in this hash
            return md5($localEntity->name . $localEntity->description);

        }

        public function getNewLocalEntity($externalEntity) {

            //new local entity. Do not need pass the external value key/hash in this time because the bind method will be called
            $localEntity = new \Customer\Entity\Customer();
            $localEntity->name = $localEntity->name;
            $localEntity->description = $localEntity->description;

            return $localEntity;

        }

        public function getUpdatedLocalEntity($localEntity, $externalEntity) {

            //edit local entity. Do not need pass the external value key/hash in this time because the bind method will be called
            $localEntity->name = $externalEntity->name;
            $localEntity->description = $externalEntity->description;

            return $localEntity;
        }

        public function getBindedLocalEntityWithExternalEntityKeyValue($localEntity, $externalEntityKeyValue) {

            //$externalEntityKeyValue string or integer value

            //set the external key value in the local entity row
            $localEntity->external_key = $externalEntityKeyValue;

            return $localEntity;
        }

        public function getBindedLocalEntityWithExternalEntityHashValue($localEntity, $externalEntityHashValue) {

            //$externalEntityHashValue string value

            //set the external hash value in the local entity row
            $localEntity->external_hash = $externalEntityHashValue;

            return $localEntity;

        }

    }
```

### ETL Schema Example

[](#etl-schema-example)

```

    {
        "name": "myETL",
        "storage": {
            "name": "myETL"
        },
        "connections": {
            "local": {
                "name": "default"
            },
            "external": {
                "name": "etl"
            }
        },
        "schemas": [
            {
                "name": "Customer",
                "description": "Customer",
                "mapper": "Customer\\ETL\\ERP\\Mapper\\Customer",
                "bulk": "5000",
                "local": {
                    "entity": "Customer\\Entity\\Customer",
                    "table": "customer",
                    "attributeKey": "id",
                    "attributeExternalKey": "external_key",
                    "attributeExternalHash": "external_hash",
                    "methodKey": "getId",
                    "methodExternalKey": "getExternalKey",
                    "methodExternalHash": "getExternalHash",
                    "statements": {
                        "joins": [["customer.type", "typeAlias"], ["customer.address", "addressAlias"]],
                        "parameters": {"name": "string:name", "birthday": "datetime:-1 year", "cost": "float:500.50", "age": "integer:10", "active": "boolean:true"},
                        "conditions": ["customer.age >= :age", "customer.active = :active", "addressAlias.street like '%street%'"]
                    },
                    "operations": {
                      "ignore": ["dispatch-delete", "dispatch-insert", "dispatch-update"]
                    }
                },
                "external": {
                    "entity": "Customer\\ETL\\ERP\\Entity\\Customer",
                    "table": "customer",
                    "attributeKey": "id",
                    "methodKey": false,
                    "statements": {
                        "joins": [["customer.type", "typeAlias", "left", "typeAlias.group = 10"], ["customer.address", "addressAlias"]],
                        "parameters": {"name": "string:name", "birthday": "datetime:-1 year", "cost": "float:500.50", "age": "integer:10", "active": "boolean:true"},
                        "conditions": ["customer.age >= :age", "customer.active = :active", "addressAlias.street like '%street%'"]
                    }
                }
            }
        ]
    }

```

### ETL Loader Example

[](#etl-loader-example)

```
\PHPBook\ETL\Configuration\Setup::setSetup((new \PHPBook\ETL\Setup())
    ->setFiles(['schema json file path 1', 'schema json file path 2'])
    ->setExceptionCatcher(function(String $message) {
        //the PHPBook ETL does not throw exceptions, but you can take it here
        //you can store $message in database or something else
    }));

?>
```

### ETL Run Example

[](#etl-run-example)

```
    $routine = new \PHPBook\ETL\Routine('myETL');

    //PRIORITY_EXTERNAL: when changes are detected in the local database and the external database, use external data
    //PRIORITY_LOCAL: when changes are detected in the local database and the external database, use local data
    $routine->priority(\PHPBook\ETL\Routine::$PRIORITY_EXTERNAL); //default
    $routine->priority(\PHPBook\ETL\Routine::$PRIORITY_LOCAL);

    //run the routine
    $routine->run();
```

You must use primary keys in both databases as a sequencial numbers because the bulk loader get rows sorting by the primary key values and the insert inclusion sort is important in this etl algorithm

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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.

###  Release Activity

Cadence

Every ~52 days

Recently: every ~114 days

Total

10

Last Release

1835d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/31623868?v=4)[dz5362](/maintainers/phpbook)[@phpbook](https://github.com/phpbook)

---

Top Contributors

[![dougdomi](https://avatars.githubusercontent.com/u/17278168?v=4)](https://github.com/dougdomi "dougdomi (10 commits)")

---

Tags

phpfastlightweightetl

### Embed Badge

![Health badge](/badges/phpbook-etl/health.svg)

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

###  Alternatives

[rubix/ml

A high-level machine learning and deep learning library for the PHP language.

2.2k1.4M28](/packages/rubix-ml)

PHPackages © 2026

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