imsuperlative / install-release-binary
Download and manage GitHub release binaries
Installs: 5
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/imsuperlative/install-release-binary
Requires
- php: ^8.4
- illuminate/support: ^12.0
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.27
- orchestra/testbench: ^10.0
- pestphp/pest: ^4.0
README
Download and install release binaries in Laravel.
Install
composer require imsuperlative/install-release-binary
Usage
Create a class for each binary and bind it in a service provider:
class Ffmpeg extends ReleaseBinary {}
// AppServiceProvider $this->app->bind(Ffmpeg::class, fn () => new Ffmpeg( new GithubBinary('btbn/ffmpeg-builds', 'v7.1', 'ffmpeg'), ));
Then use it anywhere. ensureExists() downloads and installs the binary if it's missing:
app(Ffmpeg::class)->ensureExists(); app(Ffmpeg::class)->path(); // storage/app/ffmpeg
Artisan Command
Use the WithBinaryInstall trait to cut down on boilerplate. Add {--force} to your signature and call installBinary():
use Illuminate\Console\Command; use ImSuperlative\ReleaseBinary\WithBinaryInstall; class FfmpegInstallCommand extends Command { use WithBinaryInstall; protected $signature = 'ffmpeg:install {--force}'; public function handle(Ffmpeg $ffmpeg): int { return $this->installBinary($ffmpeg); } }
Or without a dedicated class:
class FfmpegInstallCommand extends Command { use WithBinaryInstall; protected $signature = 'ffmpeg:install {--force}'; public function handle(): int { return $this->installBinary(new ReleaseBinary( new GithubBinary('btbn/ffmpeg-builds', 'v7.1', 'ffmpeg'), )); } }
Config
Publish the config to change the install path:
php artisan vendor:publish --tag=release-binary-config
// config/release-binary.php return [ 'bin_path' => null, // defaults to storage_path('app') ];
Custom Sources
Implement BinarySource to support non-GitHub sources:
use ImSuperlative\ReleaseBinary\BinarySource; class S3Binary implements BinarySource { public function filename(): string { /* ... */ } public function download(string $destination): void { /* ... */ } public function verify(string $filePath): void { /* ... */ } }