PHPackages                             frankfoerster/cakephp-bitly - 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. frankfoerster/cakephp-bitly

ActiveCakephp-plugin

frankfoerster/cakephp-bitly
===========================

CakePHP Bitly Plugin

v0.1.0(9y ago)2106MITPHPPHP &gt;=5.4.16

Since Nov 15Pushed 9y ago1 watchersCompare

[ Source](https://github.com/frankfoerster/cakephp-bitly)[ Packagist](https://packagist.org/packages/frankfoerster/cakephp-bitly)[ Docs](https://github.com/frankfoerster/cakephp-bitly)[ RSS](/packages/frankfoerster-cakephp-bitly/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

cakephp-bitly
=============

[](#cakephp-bitly)

[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.txt)[![Total Downloads](https://camo.githubusercontent.com/8b88670c8302e52ca910e6e2b25d21342f8f7d9c08f390df13718dc11144aa1b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6672616e6b666f6572737465722f63616b657068702d6269746c792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/frankfoerster/cakephp-bitly)[![Latest Stable Version](https://camo.githubusercontent.com/2c84ee4a4b5b9659db2303677eaeb9f92bbeffd51595cca7d68e1cb3cbcaf035/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6672616e6b666f6572737465722f63616b657068702d6269746c792e7376673f7374796c653d666c61742d737175617265266c6162656c3d737461626c65)](https://packagist.org/packages/frankfoerster/cakephp-bitly)

The cakephp-bitly plugin provides a wrapper for the bit.ly API to shorten long urls.

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

[](#installation)

You can install this plugin into your CakePHP application using [composer](http://getcomposer.org).

Run the following command

```
composer require frankfoerster/cakephp-bitly
```

Enable the Plugin
-----------------

[](#enable-the-plugin)

You can load the plugin using the shell command:

```
bin/cake plugin load FrankFoerster/Bitly

```

Or you can manually add the loading statement in the **config/boostrap.php** file of your application:

```
Plugin::load('FrankFoerster/Bitly');
```

Configure the Plugin
--------------------

[](#configure-the-plugin)

To use the UrlShortener you have to provide your bitly login name and your bitly API key as config entries within `/config/app.php`.

```
return [
    ...

    'Bitly' => [
        'login' => 'YOUR_LOGIN',
        'apiKey' => 'YOUR_API_KEY',

        /**
         * @link: http://book.cakephp.org/3.0/en/core-libraries/httpclient.html#proxy-authentication
         *
         * e.g.:
         * -----
         * 'proxy' => [
         *   'username' => 'foo', // optional username set in request header
         *   'password' => 'bar', // optional password set in request header
         *   'proxy' => 'tcp://localhost:9000'
         * ]
         */
        'proxy' => false
    ],

    ...
];
```

To obtain an api key sign up at [https://bitly.com/a/sign\_up](https://bitly.com/a/sign_up) .

Use the UrlShortener
--------------------

[](#use-the-urlshortener)

To use the url shortener you have to instatiate a new UrlShortener instance. It will setup your instance with the configured parameters automatically.

You can wrap your calls in a try catch block (see below), because the cakephp-bitly plugin throws custom exceptions that represent all possible error responses from the bitly API. They all extend from the BitlyException and can be handled separately via multiple catch blocks.

```
use FrankFoerster\Bitly\Exception\BitlyException;
use FrankFoerster\Bitly\UrlShortener;

$urlShortener = new UrlShortener();

try {
    $shortUrl = $urlShortener->shorten($myLongUrl);
} catch (BitlyException $e) {
    // handle any of the exceptions
}
```

The result of the shorten($url) call is a response object containing the data returned from the bit.ly API call. It consists of the following properties:

- **new\_hash** - designates if this is the first time this long\_url was shortened by this user. The return value will equal 1 the first time a long\_url is shortened. It will also then be added to the user history.
- **url** - the actual Bitlink that should be used, and is a unique value for the given Bitly account.
- **hash** - a bitly hash for long\_url which is unique to the given account.
- **global\_hash** - a bitly hash for long\_url which can be used to track aggregate stats across all Bitlinks that point to the same long\_url.
- **long\_url** - an echo back of the longUrl request parameter. This may not always be equal to the URL requested, as some URL normalization may occur (e.g., due to encoding differences, or case differences in the domain). This long\_url will always be functionally identical the the request parameter.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

3462d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5e283cec64599004f56a995fa747ed73a01870b4131e73a62cbcdfc90db1109c?d=identicon)[frankfoerster](/maintainers/frankfoerster)

---

Top Contributors

[![frankfoerster](https://avatars.githubusercontent.com/u/3206331?v=4)](https://github.com/frankfoerster "frankfoerster (4 commits)")

---

Tags

bitlycakephpcakephp-plugincakephp3phpurllibrarycakephpbitlyshortener

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/frankfoerster-cakephp-bitly/health.svg)

```
[![Health](https://phpackages.com/badges/frankfoerster-cakephp-bitly/health.svg)](https://phpackages.com/packages/frankfoerster-cakephp-bitly)
```

###  Alternatives

[yourls/yourls

Your Own URL Shortener

11.9k27.7k1](/packages/yourls-yourls)[cakephp/bake

Bake plugin for CakePHP

11211.2M156](/packages/cakephp-bake)[laracrafts/laravel-url-shortener

Powerful URL shortening tools in Laravel

97110.7k](/packages/laracrafts-laravel-url-shortener)[waavi/url-shortener

Url Shortener for Laravel 5 with support for Google and Bitly drivers.

64178.1k](/packages/waavi-url-shortener)[mremi/url-shortener-bundle

Implementation of UrlShortener library for Symfony2/Symfony3

19135.0k](/packages/mremi-url-shortener-bundle)[dereuromark/cakephp-translate

A CakePHP plugin for managing translations

1710.4k](/packages/dereuromark-cakephp-translate)

PHPackages © 2026

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