PHP code example of camillebaronnet / php-etl

1. Go to this page and download the library: Download camillebaronnet/php-etl library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

camillebaronnet / php-etl example snippets




use Camillebaronnet\ETL\Etl;
use Camillebaronnet\ETL\Extractor\Http;
use Camillebaronnet\ETL\Loader\DebugLoader;
use Camillebaronnet\ETL\Transformer\DateTime;
use Camillebaronnet\ETL\Transformer\Decode;
use Camillebaronnet\ETL\Transformer\Flatten;
use Camillebaronnet\ETL\Transformer\Map;
use Camillebaronnet\ETL\Transformer\Sleep;

$etl = (new Etl)
    ->extract(Http::class, ['url' => 'https://api.github.com/users/camillebaronnet/repos'])
    ->add(Decode::class)
    ->add(Sleep::class, ['seconds' => .2])
    ->add(Flatten::class, ['glue' => '_'])
    ->add(Map::class, [
        'fields' => [
            'id',
            'name',
            'full_name' => 'fullName',
            'owner_login' => 'ownerLogin',
            'owner_url' => 'ownerUrl',
            'url',
            'ssh_url' => 'sshUrl',
            'created_at' => 'createdAt'
        ]
    ])
    ->add(DateTime::class, [
        'fields' => ['createdAt'],
        'from' => 'Y-m-d\TH:i:s\Z',
        'to' => 'd/m/Y',
    ])
;

$etl->process(DebugLoader::class);