fabstei/shorturl-bundle
A Symfony bundle for adding short URL support to your applications. It provides services for generating short codes and resolving them back to their original destinations, with simple configuration for dropping into existing Symfony projects.
Read this first: fabstei/shorturl-bundle is a Symfony2 bundle, not a Laravel package. There is no service provider, no facade, no publishable config, and no Laravel-facing documentation. Treat it as source material to mine, not a dependency to install.
Before writing any code:
composer show fabstei/shorturl-bundle --all — confirm it is still resolvable and check the require block. Expect symfony/symfony: ~2.x and PHP 5.x constraints, which will fail composer require on a modern Laravel app.composer.json (autoload: almost certainly PSR-0, namespaced under a Fabstei\ShorturlBundle style vendor dir — check whether it loads under Composer 2 at all)DependencyInjection/*Extension.php and Resources/config/services.xml|yml — this is the real API surface; it tells you which services exist and what they're constructed withFirst realistic use case for a Laravel dev: you have an Article/Invoice/Share model and you want a stable short link (/s/abc123) for outbound sharing. The bundle's value here is close to zero — you need a short_url column, a route, and a redirect controller. The only thing worth lifting is a hashing/encoding routine, and Laravel already gives you Hashids-style options via community packages.
Minimal Laravel-side shape you'll end up building regardless:
// routes/web.php
Route::get('s/{code}', ShortUrlController::class)->name('short.redirect');
// app/Services/ShortUrl.php
class ShortUrl
{
public function make(Model $model): string { /* encode + persist */ }
public function resolve(string $code): ?Model { /* lookup */ }
}
If you genuinely want the bundle's encoder, copy that one class into app/Support/ and rewrite its namespace. Do not pull the bundle in.
Because the package is Symfony2-shaped, "patterns" here means translation patterns — how to move its concepts into Laravel idiom.
Pattern 1 — Extract the service, discard the bundle. The bundle's contribution is (a) a service definition, (b) possibly a controller/Twig helper, (c) config tree. In Laravel:
// app/Providers/ShortUrlServiceProvider.php
$this->app->singleton(ShortUrl::class, function ($app) {
return new ShortUrl(
config('shorturl.domain'),
config('shorturl.length', 7),
);
});
The constructor args are whatever the bundle's services.xml passes in — read them off the definition rather than guessing.
Pattern 2 — Config translation.
Symfony's Configuration.php tree maps 1:1 onto a config/shorturl.php returning a flat array. Copy defaults verbatim; Symfony bundles of that era often have undocumented defaults buried in the Extension class ($container->setParameter('fabstei_shorturl.foo', 'bar')).
Pattern 3 — Persistence.
If the bundle ships Doctrine entities/mappings, do not try to reuse them. Write a Laravel migration with the same columns. Doctrine annotation mappings from 2014 frequently use @ORM\... syntax that current doctrine/orm rejects, and the bundle has no Eloquent anything.
Pattern 4 — Delivery.
Any Symfony controller in the bundle (redirectAction, createAction) becomes a Laravel invokable controller. Twig helpers become Blade directives or just route('short.redirect', $model->short_code).
Pattern 5 — If you must run it (legacy app port).
The only sane integration is an adapter: boot the bundle's class manually, inject it into a Laravel singleton, and keep all Symfony container assumptions (ContainerAware, KernelInterface) satisfied with stubs. This is a day of work for a library that shortens strings; budget accordingly and expect to abandon it.
Integration tip: whichever path you take, wrap it behind your own interface (ShortenerContract) so the 2014 code is one swappable implementation and not threaded through controllers.
ServiceProvider, no Facade, no config publish, no migrations. Everything Laravel-specific is yours to write.vendor/-style directory layout. Under Composer 2's stricter autoloading this often silently fails to autoload — composer dump-autoload -o and inspect vendor/composer/autoload_namespaces.php.php: >=5.3.3 and code using each(), create_function, or short-array-less syntax. On PHP 8.2+ you'll get deprecations or fatals before you get a short URL.ContainerAwareInterface, getContainer(), @Template annotations, sensio/framework-extra-bundle — all removed or changed in Symfony 4+. Any controller in the bundle is dead code on modern stacks.Doctrine\ORM\Mapping imports from the 2.3–2.4 era will not load on doctrine/orm 2.14+. Don't attempt reuse.Extension class for setParameter and satisfy every one explicitly.LICENSE file permits the reuse you're planning (many 2014 bundles are MIT, but confirm rather than assume, especially if you're vendoring code into a commercial app).hashids/hashids or a short_urls table with a unique index and a /s/{code} redirect route. You will have a working, tested, maintainable feature in under an hour — which is roughly the time you'd spend just reading this bundle's DI config.How can I help you explore Laravel packages today?