Laravel package for generating bitly url

1.1.14 2023-02-21 13:41 UTC

This package is auto-updated.

Last update: 2024-02-13 17:40:32 UTC


A laravel package for generating Bitly short URLs.

For more information see Bitly

Build Status Latest Stable Version License Total Downloads


Laravel 5.1 or later


Installation is a quick 3 step process:

  1. Download laravel-bitly using composer
  2. Enable the package in app.php
  3. Configure your Bitly credentials
  4. (Optional) Configure the package facade

Step 1: Download laravel-bitly using composer

Add shivella/laravel-bitly by running the command:

composer require shivella/laravel-bitly

Step 2: Enable the package in app.php

Register the Service in: config/app.php


Step 3: Configure Bitly credentials

php artisan vendor:publish --provider="Shivella\Bitly\BitlyServiceProvider"

Add this in you .env file


Step 4 (Optional): Configure the package facade

Register the Bitly Facade in: config/app.php


return [
    'aliases' => [

        'App' => Illuminate\Support\Facades\App::class,
        'Artisan' => Illuminate\Support\Facades\Artisan::class,
        'Auth' => Illuminate\Support\Facades\Auth::class,
        // ...
        'Bitly' => Shivella\Bitly\Facade\Bitly::class,
    // ...



$url = app('bitly')->getUrl(''); //

Or if you want to use facade, add this in your class after namespace declaration:


use Bitly;

Then you can use it directly by calling Bitly:: like:


$url = Bitly::getUrl(''); //


In your unit tests you may use BitlyClientFake class instead of regular client. It will create a fake short URLs using hashing without calling an external REST API, which will speed up your unit tests. Fake might be setup via DI at your \Tests\TestCase::createApplication() implementation:


namespace Tests;

use Illuminate\Contracts\Console\Kernel;
use Shivella\Bitly\Testing\BitlyClientFake;

trait CreatesApplication
     * Creates the application.
     * @return \Illuminate\Foundation\Application
    public function createApplication()
        $app = require __DIR__.'/../bootstrap/app.php';


        // swap Bitly client by a fake
        $app->singleton('bitly', function () {
            return new BitlyClientFake();

        return $app;

As an alternative you may use \Shivella\Bitly\Facade\Bitly::fake() method to swap regular client by a fake.