2017 © Pedro Peláez
 

library laravel-bitly

Laravel package for generating bitly url

image

shivella/laravel-bitly

Laravel package for generating bitly url

  • Friday, September 29, 2017
  • by Shivella
  • Repository
  • 1 Watchers
  • 11 Stars
  • 10,319 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 6 Forks
  • 0 Open issues
  • 7 Versions
  • 78 % Grown

The README.md

Laravel Bitly Package

A laravel package for generating Bitly short URLs., (*1)

For more information see Bitly, (*2)

Build Status Latest Stable Version License Total Downloads, (*3)

Requirements

Laravel 5.1 or later, (*4)

Installation

Installation is a quick 3 step process:, (*5)

  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:, (*6)

composer require shivella/laravel-bitly

Step 2: Enable the package in app.php

Register the Service in: config/app.php, (*7)

``` php Shivella\Bitly\BitlyServiceProvider::class,, (*8)


### Step 3: Configure Bitly credentials ``` php artisan vendor:publish --provider="Shivella\Bitly\BitlyServiceProvider" ``` Add this in you **.env** file ``` BITLY_ACCESS_TOKEN=your_secret_bitly_access_token ``` ### Step 4 (Optional): Configure the package facade Register the Bitly Facade in: **config/app.php** ```php <?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, ], // ... ];

Usage

<?php

$url = app('bitly')->getUrl('https://www.google.com/'); // http://bit.ly/nHcn3
````

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

```php
<?php

use Bitly;

Then you can use it directly by calling Bitly:: like:, (*9)

<?php

$url = Bitly::getUrl('https://www.google.com/'); // http://bit.ly/nHcn3
````

### Testing

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:

```php
<?php

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';

        $app->make(Kernel::class)->bootstrap();

        // 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., (*10)

The Versions

29/09 2017

dev-master

9999999-dev https://github.com/Shivella/laravel-bitly

Laravel package for generating bitly url

  Sources   Download

MIT

The Requires

 

The Development Requires

by Wessel Strengholt

laravel package bitly

29/09 2017

1.0.5

1.0.5.0 https://github.com/Shivella/laravel-bitly

Laravel package for generating bitly url

  Sources   Download

MIT

The Requires

 

The Development Requires

by Wessel Strengholt

laravel package bitly

19/06 2017

1.0.4

1.0.4.0 https://github.com/Shivella/laravel-bitly

Laravel package for generating bitly url

  Sources   Download

MIT

The Requires

 

The Development Requires

by Wessel Strengholt

laravel package bitly

27/03 2017

1.0.3

1.0.3.0 https://github.com/Shivella/laravel-bitly

Laravel package for generating bitly url

  Sources   Download

MIT

The Requires

 

The Development Requires

by Wessel Strengholt

laravel package bitly

21/12 2016

1.0.2

1.0.2.0 https://github.com/Shivella/laravel-bitly

Laravel package for generating bitly url

  Sources   Download

MIT

The Requires

 

The Development Requires

by Wessel Strengholt

laravel package bitly

20/12 2016

1.0.1

1.0.1.0 https://github.com/Shivella/laravel-bitly

Laravel package for generating bitly url

  Sources   Download

MIT

The Requires

 

The Development Requires

by Wessel Strengholt

laravel package bitly

19/12 2016

1.0.0

1.0.0.0

Laravel package for generating bitly url

  Sources   Download

The Requires

 

The Development Requires

by Wessel Strengholt

laravel package bitly