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