codewithkyrian/platform-package-installer
Install the package via Composer:
composer require codewithkyrian/platform-package-installer
Publish the configuration file (if needed) to customize platform URLs:
php artisan vendor:publish --provider="CodeWithKyrian\PlatformPackageInstaller\PlatformPackageInstallerServiceProvider" --tag="config"
First Use Case: Resolve and override package URLs dynamically:
use CodeWithKyrian\PlatformPackageInstaller\Facades\PlatformPackageInstaller;
// Resolve a package URL with fallback to default if override fails
$url = PlatformPackageInstaller::resolve('vendor/package', '1.0.0');
Leverage the resolve() method to fetch package URLs with fallback logic:
// Fallback to default if override fails (new in 2.1.0)
$url = PlatformPackageInstaller::resolve('vendor/package', 'version', [
'override_key' => 'custom_url'
]);
For backward compatibility, maintain existing platform-urls config structure:
// config/platform-urls.php (legacy)
return [
'vendor/package' => [
'default' => 'https://legacy.url',
'1.0.0' => 'https://custom.url',
],
];
Use the override-resolved feature to dynamically modify resolved URLs:
// In a service provider or config
PlatformPackageInstaller::overrideResolved(function ($url, $package, $version) {
return str_replace('default', 'custom', $url);
});
override-resolved fails, the package now falls back to the default variable (e.g., default key in config) instead of throwing an error.default URL in your config to avoid unexpected fallbacks:
return [
'vendor/package' => [
'default' => 'https://fallback.url',
'1.0.0' => env('CUSTOM_URL', null),
],
];
platform-urls config key is now deprecated in favor of platform-package-installer.urls (check config/platform-package-installer.php).// Old (legacy)
'platform-urls' => [...]
// New (recommended)
'urls' => [...]
PlatformPackageInstaller::getResolvedUrl($package, $version) to inspect the resolved URL before overrides are applied.PlatformPackageInstaller::disableOverrides();
platform-package-installer.resolver service tag.PackageUrlResolved events to react to resolved URLs:
event(new PackageUrlResolved($package, $version, $url));
How can I help you explore Laravel packages today?