Laravel Packages

Shorten URLs in Your Laravel App with the Cuttly Package

Published
Shorten URLs in Your Laravel App with the Cuttly Package image

Cuttly Service is a Laravel Package that provides a convenient wrapper to the Cuttly API. It provides link shortening, editing, and statistics around shortened URLs that you create in your Laravel application:

use Slvler\Cuttly\Facades\Cuttly;
 
Cuttly::short(['short' => 'google.com']);
/*
{
"url": {
"status": 7,
"fullLink": "http://google.com",
"date": "2023-08-07",
"shortLink": "https://cutt.ly/ewdVijlY",
"title": "Google"
}
}
*/

You can conveniently retrieve stats for a shortened URL using the stats() method:

use Slvler\Cuttly\Facades\Cuttly;
 
Cuttly::stats(['stats' => 'cutt.ly/ewdVijlY']);
/*
{
"stats": {
"status": 1,
"clicks": 0,
"date": "2023-08-07",
"title": "Google",
"fullLink": "http://google.com",
"shortLink": "https://cutt.ly/ewdVijlY",
"facebook": 0,
"twitter": 0,
"pinterest": 0,
"instagram": 0,
"googlePlus": 0,
"linkedin": 0,
"rest": 0,
"devices": {},
"refs": {},
"bots": "Insufficient subscription level"
}
}
*/

You can sign up and get familiar with the Cutt.ly API by checking out the API documentation. To get started with the source code, you can check it out on GitHub at slvler/laravel-url-shortener.

Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Sponsored

laravelcloud logo
Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Visit Laravel Cloud

The latest

View all →
CPX: The Composer Package Executor for PHP image

CPX: The Composer Package Executor for PHP

Read article
Laravel AI SDK Adds Human-in-the-Loop Tool Approval image

Laravel AI SDK Adds Human-in-the-Loop Tool Approval

Read article
Pest 5 Released With Test Impact Analysis, Agent Verification, and Evals image

Pest 5 Released With Test Impact Analysis, Agent Verification, and Evals

Read article
Queue-SQL: Run Mass Deletes and Updates Across Parallel Queue Jobs image

Queue-SQL: Run Mass Deletes and Updates Across Parallel Queue Jobs

Read article
Blade Formatting in Laravel Pint image

Blade Formatting in Laravel Pint

Read article
Inertia DevTools Is Now on the Chrome Web Store image

Inertia DevTools Is Now on the Chrome Web Store

Read article