Introducing the T.LY Laravel URL Shortener API Package
If you need short links inside a Laravel app, the T.LY API already gives you the building blocks. The TLY Laravel package makes that workflow feel more native, so you can create, update, and inspect links without wiring up every request yourself.
Why Use the T.LY API for URL Shortening?
T.LY is a simple URL shortener that goes beyond just shrinking links. By leveraging the T.LY API, you can:
- Generate short URLs with ease.
- Access analytics and click metrics.
- Organize and manage your shortened URLs through tags and dashboards.
- Maintain brand consistency by using custom domains.
If you want those features inside a Laravel app, the tly/laravel-url-shortener-api package keeps the integration simple.
Getting Started
Create an API Key
- Register a T.LY Account
- Create an API Token
Installation
Install via Composer:
composer require tly/laravel-url-shortener-api
Publish the configuration:
php artisan vendor:publish --provider="TLY\\LaravelUrlShortener\\TLYServiceProvider" --tag=config
Set your API token in .env:
TLY_API_TOKEN=your_api_token_here
Examples
Create a Short Link
use TLY\LaravelUrlShortener\Facades\TLYApi;
$response = TLYApi::create([
'long_url' => 'https://example.com',
'description' => 'Example Link',
]);
Update a Short Link
use TLY\LaravelUrlShortener\Facades\TLYApi;
$response = TLYApi::update([
'short_url' => 'https://t.ly/123',
'long_url' => 'https://new-destination.com',
'description' => 'Updated Link Description',
'expire_at_datetime' => '2035-12-31 23:59:59',
]);
Delete a Short Link
use TLY\LaravelUrlShortener\Facades\TLYApi;
$response = TLYApi::delete('https://t.ly/123');
Get a Short Link
use TLY\LaravelUrlShortener\Facades\TLYApi;
$response = TLYApi::get('https://t.ly/123');
Get the stats for a Short Link
use TLY\LaravelUrlShortener\Facades\TLYApi;
$response = TLYApi::stats('https://t.ly/123');
The TLY Laravel URL Shortener API package gives Laravel apps a clean way to work with T.LY. If you need branded short links, stats, or tags, it saves you from rebuilding the same plumbing by hand.
For more details, visit the T.LY documentation.
Tim Leland
Useful Tools
Ready to improve how you manage links?
T.LY URL Shortener makes long links look cleaner and easier to share! Add your own Custom Domains to personalize your brand. Create Smart Links to customize a URL's destination. Generate QR codes to promote your business.
Sign Up for Free
