PHP code example of shyim / composer-binary-downloader

1. Go to this page and download the library: Download shyim/composer-binary-downloader 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/ */

    

shyim / composer-binary-downloader example snippets


#!/usr/bin/env php

\Bin::run('shopmon-cli');

use Shyim\BinaryDownloader\Binaries;

// a shared library
$ffi = FFI::cdef($header, Binaries::path('sasso'));

// or an executable
exec(escapeshellarg(Binaries::path('ripgrep')) . ' --version', $output);

use Shyim\BinaryDownloader\Exception\LibraryUnavailableExceptionInterface;

try {
    $ffi = FFI::cdef($header, Binaries::path('sasso'));
} catch (LibraryUnavailableExceptionInterface $e) {
    // $e->getMessage() states the cause and the fix
    return new PurePhpFallback();
}

use Shyim\BinaryDownloader\Exception\LibraryNotInstalledException;
use Shyim\BinaryDownloader\Exception\Reason;

try {
    $path = Binaries::path('sasso');
} catch (LibraryNotInstalledException $e) {
    // Respect a deliberate opt-out; retry only what is worth retrying.
    if ($e->reason() === Reason::Declined) {
        throw $e;
    }

    $path = Binaries::install('sasso');
}

$status = Binaries::status('sasso');

$status->installed;         // bool
$status->isSupported();     // false when no build exists for this platform
$status->isOverridden();    // true when <PREFIX>_LIBRARY is in effect
$status->target;            // 'aarch64-apple-darwin', or null
$status->path;              // where it is, or would be
$status->configuredTargets; // every triple the library publishes
echo $status->describe();   // one-line summary

return [
    'sasso' => [
        'package' => 'shyim/sasso-ffi',
        'version' => '0.8.2',
        'env_prefix' => 'SASSO',
        'optional' => true,
        'targets' => [
            'aarch64-apple-darwin' => [
                'path' => __DIR__ . '/../shyim/sasso-ffi/bin/aarch64-apple-darwin/libsasso.dylib',
                'library' => 'libsasso.dylib',
                'url' => 'https://github.com/shyim/sasso/releases/download/v0.8.2/...',
            ],
        ],
    ],
];
bash
php vendor/bin/binary-download
php vendor/bin/binary-download --list
php vendor/bin/binary-download sasso --target=all