PHP code example of carloshlfz / php-grf

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

    

carloshlfz / php-grf example snippets



stance a reader/writer for your grf file
$grf = new GrfFile('php-grf/tests/test200.grf');

foreach ($grf->getEntries() as $entry) {
    $dir = dirname($entry->getFilename());

    if (is_dir($dir) === false)
        mkdir ($dir, 0777, true);

    $file = str_replace('\\', '/', $entry->getFilename());
    $buffer = $entry->getUnCompressedBuffer();

    $fp = fopen($file, 'wb');
    fwrite($fp, $buffer);
    fflush($fp);
    fclose($fp);
}

// Dispose all resources used
$grf = null;


stance a reader/writer for your grf file
$grf = new GrfFile('php-grf/tests/test200.grf');

// Find all files in entries (including added)
// when uncompressed the size is more then 1000 bytes.
$search = $grf->getEntries()->where(function($entry) {
	return $entry->getUnCompressedSize() > 1000;
});

// Dispose all resources used
$grf = null;


stance a reader/writer for your grf file
$grf = new GrfFile('php-grf/tests/test200.grf');
$entries = $grf->getEntries();
$entry = $entries['data\\0_Tex1.bmp'];

if ($entry === null) { // not found

}

// Dispose all resources used
$grf = null;


// Instance a reader/writer for your grf file
$grf = new GrfFile('php-grf/tests/test200.grf');

$grf->addFile('file-outside.txt', 'data\\file-inside.txt');

// Dispose all resources used
$grf->close(); // Auto save when closed
$grf = null;


// Creates a new grf file with no files inside
$grf = GrfFile::create('your-grf-file.grf');

// Dispose all resources used
$grf->close(); // Auto save when closed
$grf = null;

composer