PHP code example of xtompie / flux

1. Go to this page and download the library: Download xtompie/flux 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/ */

    

xtompie / flux example snippets




declare(strict_types=1);

use Xtompie\Flux\Core\Program;
use Xtompie\Flux\Filter\OnceFilter;
use Xtompie\Flux\Input\LinesInput;
use Xtompie\Flux\Output\FileOutput;
use Xtompie\Flux\Start\RsyncStart;
use Xtompie\Flux\Stop\CountFileLinesStop;

Machine::new(
    program: [
        Program::new(
            name: 'default',
            start: RsyncStart::new('[email protected]:/var/nginx/logs/laravel-*', 'var/default/input'),
            input: LinesInput::new('var/default/input/'),
            filter: OnceFilter::new('var/default/once/'),
            output: FileOutput::new('log/default.log'),
            stop: CountFileLinesStop::new('log/default.log'),
        )
    ]
)
    ->run()
;




declare(strict_types=1);

use Xtompie\Flux\Core\Program;
use Xtompie\Flux\Filter\OnceFilter;
use Xtompie\Flux\Input\LinesInput;
use Xtompie\Flux\Output\FileOutput;
use Xtompie\Flux\Start\RsyncStart;
use Xtompie\Flux\Finish\CountFilesLinesFinish;

Machine::new(
    program: [
        Program::new(
            name: 'aaa',
            start: RsyncStart::new('[email protected]:/var/logs/nginx/aaa.errorlog', 'var/aaa/input'),
            input: LinesInput::new('var/aaa/input/'),
            filter: OnceFilter::new('var/aaa/once/'),
            output: FileOutput::new('log/aaa.log'),
        ),
        Program::new(
            name: 'bbb',
            start: RsyncStart::new('[email protected]:/var/logs/nginx/bbb.errorlog', 'var/bbb/input'),
            input: LinesInput::new('var/bbb/input/'),
            filter: OnceFilter::new('var/bbb/once/'),
            output: FileOutput::new('log/bbb.log'),
        ),
    ],
    finish: CountFilesLinesFinish::new('log/'),
)
    ->run()
;



declare(strict_types=1);

use Xtompie\Flux\Core\Program;
use Xtompie\Flux\Filter\OnceFilter;
use Xtompie\Flux\Input\LinesInput;
use Xtompie\Flux\Output\FileOutput;
use Xtompie\Flux\Start\RsyncStart;
use Xtompie\Flux\Stop\CountFileLinesStop;

Machine::new([
    Program::new(
        name: $name = 'dev',
        start: RsyncStart::new('user@host-dev:/var/log/nginx/application.error.log', "var/$name/input"),
        input: LinesInput::new("var/$name/input/"),
        filter: OnceFilter::new("var/$name/once/"),
        output: FileOutput::new("log/$name.log"),
        stop: CountFileLinesStop::new("log/$name.log"),
    ),
    Program::new(
        name: $name = 'test',
        start: RsyncStart::new('user@host-prod:/var/log/nginx/application.error.log', "var/$name/input"),
        input: LinesInput::new("var/$name/input/"),
        filter: OnceFilter::new("var/$name/once/"),
        output: FileOutput::new("log/$name.log"),
        stop: CountFileLinesStop::new("log/$name.log"),
    ),
])
    ->run()
;