Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Platform Package Installer Laravel Package

codewithkyrian/platform-package-installer

View on GitHub
Deep Wiki
Context7

Getting Started

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');

Implementation Patterns

Dynamic URL Resolution

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'
]);

Legacy Config Support

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',
    ],
];

Artifact URL Overrides

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);
});

Gotchas and Tips

Fallback Behavior (New in 2.1.0)

  • If override-resolved fails, the package now falls back to the default variable (e.g., default key in config) instead of throwing an error.
  • Tip: Explicitly define a default URL in your config to avoid unexpected fallbacks:
    return [
        'vendor/package' => [
            'default' => 'https://fallback.url',
            '1.0.0'    => env('CUSTOM_URL', null),
        ],
    ];
    

Backward Compatibility

  • The platform-urls config key is now deprecated in favor of platform-package-installer.urls (check config/platform-package-installer.php).
  • Migration Tip: Update your config to avoid warnings:
    // Old (legacy)
    'platform-urls' => [...]
    
    // New (recommended)
    'urls' => [...]
    

Debugging Overrides

  • Use PlatformPackageInstaller::getResolvedUrl($package, $version) to inspect the resolved URL before overrides are applied.
  • Debugging Tip: Temporarily disable overrides to isolate issues:
    PlatformPackageInstaller::disableOverrides();
    

Extension Points

  • Custom Resolvers: Extend the package by binding your own resolver to the platform-package-installer.resolver service tag.
  • Event Listeners: Listen for PackageUrlResolved events to react to resolved URLs:
    event(new PackageUrlResolved($package, $version, $url));
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle