PHP code example of skt-t1-byungi / into-one

1. Go to this page and download the library: Download skt-t1-byungi/into-one 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/ */

    

skt-t1-byungi / into-one example snippets


namespace SktT1Byungi\IntoOne;

$path = "test.bin";

var_dump(is_file($path)); //false;

IntoOne::concat($path, function ($add) {
    $add->data('key1', 'abcd');
    $add->path('key2', 'files/test.txt');
    $add->resource('key3', fopen('php://stdin', 'r'));
});

var_dump(is_file($path)); //true;

$data = IntoOne::read($path, 'key1'); // $data == 'abcd'

//for large file
$content = '';
IntoOne::readChunks($path, "key2", function ($chunk) use ($content) {
    $content .= $chunk;
});

//$content == file_get_contents("files/test.txt")

namespace SktT1Byungi\IntoOne;

$path = "test.bin";

$resource = Resource::fopen($path, 'w');
$concat = new Concat($resource);
$add = new Add($concat);

$add->data('key1', 'abcd');
$add->path('key2', 'files/test.txt');
$add->resource('key3', fopen('php://stdin', 'r'));

$concat->finish();