PHP code example of phine / phar-compact

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

    

phine / phar-compact example snippets


use Phine\Compact;
use Phine\Compact\Collection;
use Phine\Phar\Builder;
use Phine\Phar\Compact\CompactObserver;

// create the archive builder
$builder = Builder::create('example.phar');

// create the collection of compactors
$collection = new Collection();
$collection->addCompactor(new Compact\Json());
$collection->addCompactor(new Compact\Php());
$collection->addCompactor(new Compact\Xml());

// create the compactor observer
$observer = new CompactObserver($collection);

// register it with the builder subjects
$builder->observe(Builder::ADD_FILE, $observer);
$builder->observe(Builder::ADD_STRING, $observer);