bramin / cuttlylaravel
Interact with the Cutt.ly API via Laravel's Http helper and facade
v1.0.0
2022-04-09 22:12 UTC
Requires
- php: ^8.0
- guzzlehttp/guzzle: ^7.4
- illuminate/contracts: ^9.0
- spatie/laravel-package-tools: ^1.9.2
Requires (Dev)
- nunomaduro/collision: ^6.0
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^7.0
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.1
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5
- spatie/laravel-ray: ^1.26
This package is auto-updated.
Last update: 2025-05-09 15:19:16 UTC
README
Cutt.ly is a URL shortening service. This package uses Laravel's Http helper to interact with that service to create, update and delete shortened links.
Installation
You can install the package via composer:
composer require bramin/cuttlylaravel
You can publish the config file with:
php artisan vendor:publish --tag="cuttly-laravel-config"
This is the contents of the published config file:
return [ 'key' => '', 'user_domain' => '0', 'no_title' => '1', 'public' => '1', ];
Make sure to set the key to your key from Cutt.ly
Usage
Include the Cuttly Facade
use Bramin\CuttlyPHP\Facades\Cuttly;
Test the api status
$success = Cuttly::ping();
Create a new link:
$details = Cuttly::create('https://google.com', '', false, true, true);
Parameters:
short
: The URL to be shortened (required)name
: The first and only uri segment after the domain name. Passing null or an empty array will generate a random and unique string.userDomain
: whether it should use the custom domain name instead of cutt.ly. Defaults tofalse
.noTitle
: Disables the title lookup to improve speed. Defaults totrue
.public
: Whether the link is public or private. Defaults totrue
.
Link analytics:
$success = Cuttly::getAnalytics('https://cutt.ly/abcd', '2022-04-01', '2022-05-01');
Parameters:
short
: The URL to be shortened (required)dateFrom
: Sets the start date of the period to return data for. Format:YYYY-MM-DD
, e.g.2021-03-02
dateTo
: Sets the end date of the period to return data for. Format:YYYY-MM-DD
, e.g.2021-03-02
Add a tag to a link:
$success = Cuttly::addTag('https://cutt.ly/abcd', 'tagname');
Update the source of a link:
$success = Cuttly::updateSource('https://cutt.ly/abcd', 'http://www.google.com');
Update the title of a link:
$success = Cuttly::updateTitle('https://cutt.ly/abcd', 'Google Home Page');
Delete a link:
$success = Cuttly::delete('https://cutt.ly/abcd');
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.