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
Extract- File Finder

The ExternalFileFinder operation is the base operation for importing files from remote or external file systems. It is responsible for locating files based on a given pattern and returning them as ExternalFileItems for further processing.

This operation works with any file system supported by Flysystem, including SFTP, local files, AWS S3, and more.


How It Works

The ExternalFileFinder searches a directory for files matching a provided pattern. For each file found, it returns an ExternalFileItem. These items are typically passed down the chain to:

  • Copy the file locally using a dedicated operation.
  • Read/process the file content using format-specific operations (e.g., csv-read, xml-read, etc.).

šŸ“˜ Refer to the Cookbook section for complete examples of end-to-end remote file import flows.


Registering the Operation

Because multiple instances of this operation may be needed (e.g., different connections or directories), the ExternalFileFinder must be manually registered using a factory.

Here is how you would register an instance using a local file system:

🐘 Standalone

$builder->registerFactory(
    new ExternalFileFinderFactory(
        'external-file-finder-local', 
        ExternalFileFinderOperation::class, 
        new LocalFileSystem("/") // or any Flysystem-compatible adapter
    )
);

You can use any Flysystem adapter (e.g., SFTP, AWS S3, Azure Blob Storage, etc.) when creating the factory.

šŸŽµ Symfony

In a Symfony application, you should register the operation via Dependency Injection, defining it as a service and tagging it accordingly.

services:
  app.etl.operation.external_file_finder.my-local:
    class: Oliverde8\Component\PhpEtl\Builder\Factories\Extract\ExternalFileFinderLocal
    autowire: true
    arguments:
      $operation: 'my_custom_finder'
      $class: 'Oliverde8\Component\PhpEtl\ChainOperation\Extract\ExternalFileFinderOperation'
      $filesystem: '@your.flysystem.adapter.service'
    tags:
      - { name: etl.operation-factory }

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)