Skip to content

Commit

Permalink
Added project facade and updated README.md with how to use it (#4)
Browse files Browse the repository at this point in the history
Added project facade and updated README.md with how to use it
  • Loading branch information
viniciusls authored and Shivella committed Sep 29, 2017
1 parent 7bc7f1e commit f54dfac
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/vendor/
/bin/
composer.lock
/.idea/*
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ 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

Expand Down Expand Up @@ -48,9 +49,33 @@ 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
'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
use Bitly;
```
Then you can use it directly by calling `Bitly::` like:
``` php
$url = Bitly::getUrl('https://www.google.com/'); // http://bit.ly/nHcn3
````
16 changes: 16 additions & 0 deletions src/Shivella/Bitly/Facade/Bitly.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
/**
* (c) Vinícius Silva <[email protected]>
*/

namespace Shivella\Bitly\Facade;


use Illuminate\Support\Facades\Facade;

class Bitly extends Facade
{
protected static function getFacadeAccessor() {
return 'bitly';
}
}

0 comments on commit f54dfac

Please sign in to comment.