adeelnawaz/polr-api-bundle
Symfony 4/5 bundle wrapping adeelnawaz/polr-api-client to integrate the Polr URL shortener REST API. Provides a PolrApiService for calling endpoints with DTOs, supports API quota throttling, and throws ApiResponseException on failures.
adeelnawaz/polr-api-client, which is a PHP library for the Polr URL shortener API. The core functionality (e.g., URL shortening, analytics, user management) is preserved, but Symfony-specific features (e.g., event dispatchers, Twig integration) may not translate directly to Laravel.PolrApiService) can be treated as a thin client layer. Laravel’s HTTP client or Guzzle could replicate this functionality with minimal overhead.polr-api-client package, which is a pure PHP library. This reduces risk of Symfony-specific conflicts in a Laravel context.polr_api.yml) can be mapped to Laravel’s .env or config/polr.php with minimal effort. Environment variables (%env%) are already Laravel-compatible.PolrApiService can be injected into Laravel’s container via a service provider or facade, mirroring Symfony’s DI approach.polr.api.event). Laravel’s event system is compatible but requires manual mapping.symfony/http-client) could introduce version constraints.api_quota feature relies on rate-limiting logic in the client. Laravel’s HTTP client or Guzzle can replicate this with middleware (e.g., throttle).polr-api-client.polr-api-client support all required Polr API endpoints (e.g., webhooks, custom domains)? If not, will custom HTTP calls be needed?api_key the only auth method? If Polr supports OAuth or tokens, will the bundle need extension?api_quota delay is implemented in PHP. Could this cause latency in high-throughput Laravel apps? Alternative: Use HTTP client middleware for rate-limiting.polr-api-client) becomes deprecated, will the bundle be maintained?polr-api-client) is PHP-agnostic, making it suitable for Laravel with minimal adaptation.Http client or Guzzle (if advanced features like middleware are needed).polr_api.yml with config/polr.php and use Laravel’s .env for variables.PolrApiService via a service provider or facade.polr-api-client without the bundle to avoid overhead.polr-api-client via Composer:
composer require adeelnawaz/polr-api-client
PolrServiceProvider) to:
PolrApiService to Laravel’s container.config/polr.php (mapped from polr_api.yml).config('polr.api_url')).use Adeelnawaz\PolrApiClient\PolrApi;
use Illuminate\Support\ServiceProvider;
class PolrServiceProvider extends ServiceProvider {
public function register() {
$this->mergeConfigFrom(__DIR__.'/../config/polr.php', 'polr');
$this->app->singleton('polr.api', function ($app) {
return new PolrApi(
$app['config']['polr.api_url'],
$app['config']['polr.api_key'],
$app['config']['polr.api_quota']
);
});
}
}
Polr::shorten($url)) for convenience:
// app/Facades/Polr.php
namespace App\Facades;
use Illuminate\Support\Facades\Facade;
class Polr extends Facade {
protected static function getFacadeAccessor() { return 'polr.api'; }
}
// app/Http/Middleware/PolrRateLimit.php
public function handle($request, Closure $next) {
$limit = config('polr.api_quota');
if ($limit > 0) {
sleep(60 / $limit); // Simplistic; use a queue for production.
}
return $next($request);
}
config/) is straightforward.polr-api-client supports Laravel’s PHP version (8.0+). Check composer.json for constraints.polr-api-client.polr-api-client independently before integrating the bundle.polr_api.yml to Laravel’s config system.polr-api-client can be managed independently.polr_api.yml → config/polr.php mapping is incorrect. Use Laravel’s config caching to mitigate.polr-api-client for breaking changes.$this->app->when('polr.api')
->needs(\Psr\Log\LoggerInterface::class)
->give(\Illuminate\Support\Facades\Log::class);
polr-api-client issues.polr-api-client directly. The bundle adds negligible abstraction.How can I help you explore Laravel packages today?