PHPackages                             pollora/datamorph - 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. [Database &amp; ORM](/categories/database)
4. /
5. pollora/datamorph

ActiveLibrary[Database &amp; ORM](/categories/database)

pollora/datamorph
=================

Powerful Flow PHP ETL integration for Laravel

2.0(1y ago)1544↓67.9%MITPHPPHP ^8.2

Since Feb 28Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Pollora/DataMorph)[ Packagist](https://packagist.org/packages/pollora/datamorph)[ RSS](/packages/pollora-datamorph/feed)WikiDiscussions main Synced 2d ago

READMEChangelogDependencies (7)Versions (3)Used By (0)

Datamorph
=========

[](#datamorph)

Datamorph is a Laravel package that allows you to create and run Flow PHP ETL (Extract, Transform, Load) pipelines in a structured and extensible way. This documentation will guide you through the installation, configuration, and usage of the package.

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Concepts](#concepts)
- [Configuration](#configuration)
- [Creating an ETL Pipeline](#creating-an-etl-pipeline)
- [Running an ETL Pipeline](#running-an-etl-pipeline)
- [Hooks](#hooks)
- [Concrete Examples](#concrete-examples)

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require pollora/datamorph
```

Concepts
--------

[](#concepts)

Datamorph is built around three main components:

1. **Extractors**: Retrieve data from various sources (databases, APIs, files, etc.)
2. **Transformers**: Transform the retrieved data according to your needs
3. **Loaders**: Load the transformed data to their final destination

These three components are orchestrated in a **Pipeline** that also manages **Hooks** that allow you to intervene at different stages of the process.

Configuration
-------------

[](#configuration)

Publish the configuration file:

```
php artisan vendor:publish --tag=datamorph-config
```

This will create a `config/datamorph.php` file where you can configure your ETL pipelines:

```
return [
    'pipelines' => [
        'stock' => [
            'hooks' => [
                'before_extract' => [
                    App\ETL\Stock\Hooks\BeforeStockExtract::class,
                ],
                'after_extract' => [
                    // Hooks to execute after extraction
                ],
                'before_transform' => [
                    // Hooks to execute before transformation
                ],
                'after_transform' => [
                    // Hooks to execute after transformation
                ],
                'before_load' => [
                    // Hooks to execute before loading
                ],
                'after_load' => [
                    // Hooks to execute after loading
                ],
                'before_run' => [
                    App\ETL\Stock\Hooks\BeforeStockRun::class,
                ],
                'after_run' => [
                    // Hooks to execute after complete execution
                ],
            ],
        ],
        // Other pipelines...
    ],
];
```

Creating an ETL Pipeline
------------------------

[](#creating-an-etl-pipeline)

### Automatic File Generation

[](#automatic-file-generation)

Datamorph includes an Artisan command that automatically generates the necessary files for a new pipeline:

```
php artisan datamorph:make product
```

This command will create the following files in the `app/ETL/Product/` directory:

- `ProductExtractor.php` - For data extraction
- `ProductTransformer.php` - For data transformation
- `ProductLoader.php` - For loading transformed data

### Structure of Generated Files

[](#structure-of-generated-files)

#### Extractor

[](#extractor)

```
