PHPackages                             toneflix-code/cuttly-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. toneflix-code/cuttly-php

ActiveLibrary[API Development](/categories/api)

toneflix-code/cuttly-php
========================

A PHP wrapper for Cutt.ly.

1.0.2(1y ago)0843[5 PRs](https://github.com/toneflix/cuttly-php/pulls)1MITPHPPHP ^8.1|^8.2|^8.3CI passing

Since Sep 3Pushed 2mo agoCompare

[ Source](https://github.com/toneflix/cuttly-php)[ Packagist](https://packagist.org/packages/toneflix-code/cuttly-php)[ Docs](https://github.com/toneflix/cuttly-php)[ RSS](/packages/toneflix-code-cuttly-php/feed)WikiDiscussions main Synced 2w ago

READMEChangelogDependencies (7)Versions (10)Used By (1)

Cutt.ly PHP
===========

[](#cuttly-php)

[![Test & Lint](https://github.com/toneflix/cuttly-php/actions/workflows/run-tests.yml/badge.svg?branch=main)](https://github.com/toneflix/cuttly-php/actions/workflows/run-tests.yml)[![Latest Stable Version](https://camo.githubusercontent.com/2c907833b907fcaf05b85409219b8ec54ef841150076bee7cb15fe2cf0ad33fc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746f6e65666c69782d636f64652f637574746c792d7068702e737667)](https://packagist.org/packages/toneflix-code/cuttly-php)[![Total Downloads](https://camo.githubusercontent.com/aad11e6f0435f3a98e3eea8b391db9c485bc3975b40e22c62c65f26ff96a6451/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746f6e65666c69782d636f64652f637574746c792d7068702e737667)](https://packagist.org/packages/toneflix-code/cuttly-php)[![License](https://camo.githubusercontent.com/e7733e4ca86c1c1d0339e1f5a2311e7d5bff051dd4767023fc7ce75406cb3fd4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f746f6e65666c69782d636f64652f637574746c792d7068702e737667)](https://packagist.org/packages/toneflix-code/cuttly-php)[![PHP Version Require](https://camo.githubusercontent.com/c6bc2231161d3cfbe0e1308583e92f8f00ca7abba86b8bfb98e8962c46c1e2fe/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f746f6e65666c69782d636f64652f637574746c792d7068702f706870)](https://packagist.org/packages/toneflix-code/cuttly-php)[![codecov](https://camo.githubusercontent.com/2bc1b0c5a030793f1e0f59fdd98c09f6aa14eff917578feccdd733e3e3fe8e67/68747470733a2f2f636f6465636f762e696f2f67682f746f6e65666c69782f637574746c792d7068702f67726170682f62616467652e7376673f746f6b656e3d324f376146756c513950)](https://codecov.io/gh/toneflix/cuttly-php)

Cutt.ly is a Link Management Platform with all features you need in one place. Shorten your links, track clicks, and boost your brand with our all-in-one URL Shortener. Create custom short links, generate QR codes, build link-in-bio pages, and gather feedback with surveys. Start optimizing your URLs today and see the impact!y, this library aims to work around the Cutt.ly API implementation by providing a simple PHP wrapper arround it.

Please refere to [Cutt.ly API Documentation](https://cutt.ly/cuttly-api) for detailed api use description as this package tries to mirror the API in the best possible way.

If you use Laravel you might also want to checkout [Cuttly Laravel](https://github.com/toneflix/cuttly-laravel)

Requirements
------------

[](#requirements)

- [PHP &gt;= 8.1](http://php.net/)
- [Guzzle, PHP HTTP client &gt;= 7.1](https://github.com/guzzle/guzzle) - Auto installs with composer
- [PHP dotenv &gt;= 5.6](https://github.com/vlucas/phpdotenv) - Auto installs with composer

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require toneflix-code/cuttly-php
```

Initialization
--------------

[](#initialization)

To start using this library you are required to configure your API keys in a .env file with these variables.

```
CUTTLY_API_KEY=your-cutt.ly-API-key
CUTTLY_TEAM_API_KEY=your-cutt.ly-API-key #[Optional] For users with team subscriptions.
```

If your project does not have a .env file, you can create one at the root directory of your project. Alternatively your can pass the api key as parameters when you [initialize the library](#without-env-file).

### With ENV file

[](#with-env-file)

```
use ToneflixCode\CuttlyPhp\Cuttly;

$cutly = new Cuttly();
```

### Without ENV file

[](#without-env-file)

```
use ToneflixCode\CuttlyPhp\Cuttly;

$cutly = new Cuttly(
    apiKey: '121hksdSome23hRandom19212RegularApiKeyString55',
    teamApiKey: 'hksd092uSome00uRandom101nTeamApiKeyStrings31'
);
```

#### Initialization Errors

[](#initialization-errors)

Where an API key is not provided, the library will throw a `ToneflixCode\CuttlyPhp\Exceptions\InvalidApiKeyException` exception and any other associated action call.

Regular API Usage
-----------------

[](#regular-api-usage)

### Shorten Url

[](#shorten-url)

To shorten a URL simply call the `shorten(string)` method chained to the `regular()` method of the `Cuttly` instance passing the link you intend to shorten as the only parameter.

```
use ToneflixCode\CuttlyPhp\Cuttly;

$cutly = new Cuttly();

$link = 'https://toneflix.com.ng/learning';
$data = $cutly->regular()->shorten($link);
```

The `shorten()` method returns an instance of `ToneflixCode\CuttlyPhp\Builders\ShortenResponse` which contains all properties of the request response [returned by the API](https://cutt.ly/api-documentation/regular-api).

### Chainable parameters

[](#chainable-parameters)

We have taken our time to ensure that while using this library, you have access to every available feature provided by cuttly in the first place, here is a list of parameters you can chain as methods to further customize your request.

- `name(string)`: Your desired short link - alias - if not already taken
- `noTitle()`: Faster API response time - This parameter disables getting the page title from the source page meta tag which results in faster API response time Available for Team Enterprise plan
- `public()`: Settings public click stats for shortened link via AP
- `userDomain()`: Use the domain from the user account that is approved and has the `status: active`.

#### Example Usage

[](#example-usage)

```
use ToneflixCode\CuttlyPhp\Cuttly;

$cutly = new Cuttly();

$link = 'https://toneflix.com.ng/learning';
$data = $cutly->regular()->name('toneflix101')->shorten($link);
```

Do note that `shorten()` should only be called at the end of the chain.

### Edit Short Link

[](#edit-short-link)

The library also allows you to edit the short links you have created. To edit a link simply call the `edit(string)` method chained to the `regular()` method of the `Cuttly` instance passing the short link you intend to edit as the only parameter.

```
use ToneflixCode\CuttlyPhp\Cuttly;

$cutly = new Cuttly();

$link = 'https://cutt.ly/toneflix101';
$data = $cutly->regular()->edit($link);
```

Of course, the example above really does nothing and will throw a `ToneflixCode\CuttlyPhp\Exceptions\FailedRequestException`. To actually edit a link, you can chain any of the below methods to your call and voila.

- `name(string)`: New alias / name, if not already taken.
- `userDomain()`: Use the domain from the user account that is approved and has the `status: active`.
- `tag(string)`: The TAG you want to add for shortened link.
- `source(string)`: Change the source url of shortened link.
- `unique(0|1|15-1440)`: Sets a unique stat count for a short link.
- `title()`: It will change the title of url of shortened link.

#### Example Usage

[](#example-usage-1)

```
use ToneflixCode\CuttlyPhp\Cuttly;

$cutly = new Cuttly();

$link = 'https://cutt.ly/toneflix101';
$data = $cutly->regular()->name('toneflix404')->userDomain()->unique(1)->edit($link);
```

The `edit()` method returns an instance of `ToneflixCode\CuttlyPhp\Builders\BaseResponse` which contains all properties of the request response [returned by the API](https://cutt.ly/api-documentation/regular-api).

### Link analytics

[](#link-analytics)

In order to access URL statistics call the `stats(string)` method chained to the `regular()` method of the `Cuttly` instance passing the short link you intend to get analytics of as the only parameter.

```
use ToneflixCode\CuttlyPhp\Cuttly;

$cutly = new Cuttly();

$link = 'https://cutt.ly/toneflix404';
$data = $cutly->regular()->stats($link);
```

The `stats()` method returns an instance of `ToneflixCode\CuttlyPhp\Builders\StatsResponse` which contains all properties of the request response [returned by the API](https://cutt.ly/api-documentation/regular-api).

### Delete Short Link

[](#delete-short-link)

To delete a short link call the `delete(string)` method chained to the `regular()` method of the `Cuttly` instance passing the short link you intend to get delete as the only parameter.

```
use ToneflixCode\CuttlyPhp\Cuttly;

$cutly = new Cuttly();

$link = 'https://cutt.ly/toneflix404';
$data = $cutly->regular()->delete($link);
```

The `delete()` method returns an instance of `ToneflixCode\CuttlyPhp\Builders\BaseResponse` which contains all properties of the request response [returned by the API](https://cutt.ly/api-documentation/regular-api).

Team API Usage
--------------

[](#team-api-usage)

The team API implements the same methods and chainable methods available to the Regular API with a few exceptions that we will point out next.

TO use the Team API, instead of calling the `regular()` method on the `Cuttly` instance, we're going to call the `team()` method, you can now chain all the method we have highlighted above to use the Team API.

### Shorten Link

[](#shorten-link)

```
use ToneflixCode\CuttlyPhp\Cuttly;

$cutly = new Cuttly();

$link = 'https://toneflix.com.ng/learning';
$data = $cutly->team()->name('toneflix301')->shorten($link);
```

### Edit Short Link

[](#edit-short-link-1)

```
use ToneflixCode\CuttlyPhp\Cuttly;

$cutly = new Cuttly();

$link = 'https://cutt.ly/toneflix301';
$data = $cutly->team()->edit($link);
```

### Link analytics

[](#link-analytics-1)

```
use ToneflixCode\CuttlyPhp\Cuttly;

$cutly = new Cuttly();

$link = 'https://cutt.ly/toneflix301';
$data = $cutly->team()->stats($link);
```

### Delete Short Link

[](#delete-short-link-1)

```
use ToneflixCode\CuttlyPhp\Cuttly;

$cutly = new Cuttly();

$link = 'https://cutt.ly/toneflix404';
$data = $cutly->team()->delete($link);
```

Exceptions
----------

[](#exceptions)

### `ToneflixCode\CuttlyPhp\Exceptions\InvalidApiKeyException`

[](#toneflixcodecuttlyphpexceptionsinvalidapikeyexception)

The `ToneflixCode\CuttlyPhp\Exceptions\InvalidApiKeyException` exception is thrown whenever an API key has not been provided or an invalid API key has been provided.

### `ToneflixCode\CuttlyPhp\Exceptions\FailedRequestException`

[](#toneflixcodecuttlyphpexceptionsfailedrequestexception)

The `ToneflixCode\CuttlyPhp\Exceptions\FailedRequestException` exception is thrown whenever the Cuttly API returns an error.

### Exception Handling

[](#exception-handling)

When you hit an exception, you can handle it in whatever way is best for your use case.

```
use ToneflixCode\CuttlyPhp\Cuttly;
use ToneflixCode\CuttlyPhp\Exceptions\FailedRequestException;

$cutly = new Cuttly();

try {
  $link = 'https://toneflix.com.ng/learning';
  $data = $cutly->regular()->name('toneflix404')->shorten($link);
} catch (FailedRequestException $th) {
  echo $th->getMessage();
}
```

```
use ToneflixCode\CuttlyPhp\Cuttly;
use ToneflixCode\CuttlyPhp\Exceptions\InvalidApiKeyException;
use ToneflixCode\CuttlyPhp\Exceptions\FailedRequestException;

try {
  $cutly = new Cuttly();

  $link = 'https://toneflix.com.ng/learning';
  $data = $cutly->regular()->name('toneflix404')->shorten($link);
} catch (FailedRequestException|InvalidApiKeyException $th) {
  echo $th->getMessage();
}
```

For detailed descriptino about what is obtainable from the API, please read the [Cutt.ly Documentations](https://cutt.ly/api-documentation/regular-api).

Testing
-------

[](#testing)

```
composer test
```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Toneflix Code](https://github.com/toneflix)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance62

Regular maintenance activity

Popularity17

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 50% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

3

Last Release

656d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4638f9de973d94753ebff641af3009e1049064f9a6bd76fe87e58d0d8ddd7ca7?d=identicon)[3m1n3nc3](/maintainers/3m1n3nc3)

---

Top Contributors

[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (4 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (4 commits)")

---

Tags

apilinkslink shorteningtoneflix-codecuttlycuttly-laravelcuttly-php

###  Code Quality

TestsPest

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/toneflix-code-cuttly-php/health.svg)

```
[![Health](https://phpackages.com/badges/toneflix-code-cuttly-php/health.svg)](https://phpackages.com/packages/toneflix-code-cuttly-php)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M2.9k](/packages/craftcms-cms)[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k12](/packages/tempest-framework)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3661.2M46](/packages/tencentcloud-tencentcloud-sdk-php)[files.com/files-php-sdk

Files.com PHP SDK

2478.1k](/packages/filescom-files-php-sdk)[jasara/php-amzn-selling-partner-api

A fluent interface for Amazon's Selling Partner API in PHP

1348.1k1](/packages/jasara-php-amzn-selling-partner-api)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

232.5k](/packages/eslazarev-wildberries-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
