PHP code example of itgalaxy / bin-wrapper

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

    

itgalaxy / bin-wrapper example snippets



use Itgalaxy\BinWrapper\BinWrapper;

$url = 'https://github.com/itgalaxy/pngquant-bin/raw/master/bin-vendor';
$platform = strtolower(PHP_OS);
$binWrapper = new BinWrapper();
$binWrapper
    ->src($url . '/freebsd/x64/pngquant', 'darwin', 'x64')
    ->src($url . '/linux/x64/pngquant', 'linux', 'x64')
    ->src($url . '/linux/x86/pngquant', 'linux', 'x86')
    ->src($url . '/macos/pngquant', 'darwin')
    ->src($url . '/win/pngquant.exe', 'windowsnt')
    ->dest(__DIR__ . '/vendor-bin')
    ->using(substr($platform, 0, 3) === 'win' ? 'pngquant.exe' : 'pngquant')
    ->version('>=1.71');

$binWrapper->run(['--version']); // You can use `try {} catch {}` for catching exceptions


echo $binWrapper->path();