rezzza/shorty-bundle
Rezzza ShortyBundle integrates the Shorty URL shortener with Symfony applications. It provides configurable shortener services and Twig helpers so you can generate and display shortened links from controllers, services, or templates, making it useful for marketing links, sharing, and redirect-friend...
This is a Symfony bundle, not a Laravel package, so the first decision is whether you are maintaining a legacy Symfony 2/3 app or trying to use the underlying shortening logic from Laravel. If you are on Laravel, do not expect composer require rezzza/shorty-bundle to just work: there is no Laravel service provider, no facade, and the bundle is pinned to an old Symfony/PHP era.
Where to look first:
composer.json — confirm the Symfony/PHP constraints before attempting an install.README.md — expected config shape and Twig/service usage.DependencyInjection/Configuration.php — the authoritative list of provider options.Resources/config/services.xml (or YAML) — the service ID to inject, typically the shortener service.rezzza/shorty library it wraps — provider classes and HTTP client requirements.Minimal Symfony usage:
composer require rezzza/shorty-bundle
Register the bundle in AppKernel.php, configure a provider and credentials, then use the service:
// Symfony controller
$shortUrl = $this->get('shorty')->shorten('https://example.com/a/very/long/path?with=query');
<a href="{{ long_url|shorty }}">{{ long_url|shorty }}</a>
For Laravel, the realistic first use case is to install only the underlying rezzza/shorty library, wrap it in your own service provider/facade, or simply implement a small adapter around the provider API you actually use. Treat the bundle as a reference implementation, not a dependency.
Wrap the shortener behind an application service. Never call the bundle service directly from many controllers or templates. Create one Shortener/LinkShortener abstraction that handles caching, validation, logging, and provider fallback. That keeps the abandoned package at the edge of your codebase.
final class LinkShortener
{
public function __construct(
private object $shorty,
private CacheInterface $cache,
private LoggerInterface $logger,
) {}
public function shorten(string $url): string
{
$key = 'shorty:' . sha1($url);
return $this->cache->remember($key, 86400, function () use ($url) {
try {
return $this->shorty->shorten($url);
} catch (\Throwable $e) {
$this->logger->error('Shortening failed', ['url' => $url, 'e' => $e]);
throw $e;
}
});
}
}
Cache aggressively. Short URLs are stable for a given long URL in most use cases. Store the mapping in Redis/database keyed by a hash of the long URL, and optionally store the provider and creation date. This avoids latency, rate limits, and duplicate provider calls when rendering listing pages.
Do shortening asynchronously for bulk work. If you are shortening links in emails, notifications, imports, or social posts, queue the work. A synchronous call to Bitly or another provider during a web request is a reliability and latency problem.
Use a provider fallback chain. The package era assumes one configured provider. In practice, providers change APIs or go down. Wrap two providers and try the primary, then the fallback, and log which one succeeded.
Avoid template-time API calls in loops. The Twig filter is convenient for a single link, but rendering a page with 50 links should use pre-shortened values from your model or cache, not 50 provider calls during rendering.
Laravel integration pattern. If you must use the library from Laravel, bind it as a singleton:
$this->app->singleton(LinkShortener::class, function ($app) {
return new LinkShortener(
// construct the rezzza/shorty client here
$app->make(Cache::class),
$app->make(Logger::class),
);
});
Then expose a Blade directive or helper only if it is safe to call synchronously.
Testing pattern. Never hit the real provider in tests. Inject a fake shortener or use the underlying HTTP client’s mock handler. Assert that your service caches and that failures are logged and surfaced predictably.
composer.json before spending time on integration.rezzza/shorty.DependencyInjection/Configuration.php rather than guessing YAML keys from blog posts. Keep credentials in environment variables, never in committed config.LinkShortener service over subclassing bundle internals. If you need a new provider, implement the underlying provider interface and register it in your own service definition rather than editing vendor code.|shorty filter is fine for one-off admin screens, but it hides I/O in presentation. Avoid it in production listing pages and loops.How can I help you explore Laravel packages today?