Logo of php-etl
Getting Started
🐘 Standalone 🎵 Symfony 🦢 Sylius
Core Concepts
The Concept Execution Context Item Types Custom Operations Glossary FAQ
⛓️ Operations
Building Blocks
Split Merge Repeat Safe
Extract
File Finder CSV JSON
Transform
External File Processor Filter Data Rule Transformer Split Item HTTP Client Log Callback
Aggregation
Simple Grouping
Load
CSV JSON
🧑‍🍳 Cookbook
Without Context
Grouping / Aggregation Filtering Splitting/Forking Making your chains configurable Complex data to csv / Flatten Data Api to CSV N°1 Api to CSV N°2 Sub chains
With Context
Api to CSV Import external file
Custom Operations

PHP-ETL - Operations
Building Blocks - Chain Repeat(repeat)

The repeat operation executes a chain of operations repeatedly until a specified condition is met. This is useful for processing data in a loop, such as paginating through API results or processing a file until its end.

Options

  • chain: The chain of operations to be executed in each iteration.
  • while: An expression that determines whether the loop should continue. The expression is evaluated before each iteration. The loop continues as long as the expression evaluates to true.
  • allow_async: (Optional) A boolean that specifies whether the operations within the loop can be executed asynchronously. Defaults to false.

Example

Here’s an example of how to use the repeat operation to fetch and process data from a paginated API:

chain:
  - operation: repeat
    options:
      while: "context.page <= context.totalPages"
      allow_async: true
      chain:
        - operation: http-request
          options:
            url: "https://api.example.com/data?page="
            method: GET

        - operation: rule-transformer
          options:
            # Rules to transform the API response.

        - operation: load-to-database
          options:
            # Options to load the data into a database.

        - operation: expression
          options:
            expression: "context.page = context.page + 1"

Network

GitHub Repo Issues Good First Issues

Help Preserve This Project

Support for the continued development of php ETL. I maintain this project in my free time.

Support
Free & Open Source (MIT)