1
- # laravel-url-shortener
2
- Powerful URL shortening tools in Laravel
1
+ # Url Shortener for Laravel
2
+ Powerful URL shortening tools for your Laravel
3
3
4
4
<p align =" center " >
5
- <a href="https://travis-ci.org/LaraCrafts/laravel-url-shortener"><img src="https://travis-ci.org/LaraCrafts/laravel-url-shortener.svg?branch=master"></a>
6
- <a href="https://packagist.org/packages/laracrafts/laravel-url-shortener"><img src="https://poser.pugx.org/laracrafts/laravel-url-shortener/downloads"></a>
7
- <a href="https://packagist.org/packages/laracrafts/laravel-url-shortener"><img src="https://poser.pugx.org/laracrafts/laravel-url-shortener/version"></a>
8
- <a href="https://scrutinizer-ci.com/g/LaraCrafts/laravel-url-shortener/"><img src="https://scrutinizer-ci.com/g/LaraCrafts/laravel-url-shortener/badges/coverage.png?b=master"></a>
9
- <a href="https://packagist.org/packages/laracrafts/laravel-url-shortener"><img src="https://poser.pugx.org/laracrafts/laravel-url-shortener/license"></a>
5
+ <a href="https://packagist.org/packages/binary-cats/laravel-url-shortener"><img src="https://poser.pugx.org/binary-cats/laravel-url-shortener/downloads"></a>
6
+ <a href="https://packagist.org/packages/binary-cats/laravel-url-shortener"><img src="https://poser.pugx.org/binary-cats/laravel-url-shortener/version"></a>
7
+ <a href="https://scrutinizer-ci.com/g/binary-cats/laravel-url-shortener/"><img src="https://scrutinizer-ci.com/g/binary-cats/laravel-url-shortener/badges/coverage.png?b=master"></a>
8
+ <a href="https://packagist.org/packages/binary-cats/laravel-url-shortener"><img src="https://poser.pugx.org/binary-cats/laravel-url-shortener/license"></a>
10
9
</p >
11
10
12
11
- [ Installation] ( #installation )
13
12
- [ Requirements] ( #requirements )
13
+ - [ Laravel 8+] ( #laravel-8 )
14
14
- [ Laravel 5.5+] ( #laravel-55 )
15
15
- [ Laravel 5.1-5.4] ( #laravel-51-54 )
16
+ - [ Configuration] ( #configuration )
16
17
- [ Usage] ( #usage )
17
18
- [ Changing the driver] ( #changing-the-driver )
18
19
- [ Adding your own drivers] ( #adding-your-own-drivers )
@@ -30,12 +31,12 @@ Powerful URL shortening tools in Laravel
30
31
- [ Contributing] ( #contributing )
31
32
- [ Credits] ( #credits )
32
33
- [ License] ( #license )
33
-
34
+
34
35
## Installation
35
36
You can easily install this package using Composer, by running the following command:
36
37
37
38
``` bash
38
- composer require laracrafts /laravel-url-shortener
39
+ composer require binary-cats /laravel-url-shortener
39
40
```
40
41
41
42
### Requirements
@@ -44,6 +45,9 @@ This package has the following requirements:
44
45
- PHP 7.1 or higher
45
46
- Laravel 5.1 or higher
46
47
48
+ ### Laravel 8+
49
+ If you use Laravel 8 you must have PHP 7.3 or higher (which is a root laravel requirment)
50
+
47
51
### Laravel 5.5+
48
52
If you use Laravel 5.5 or higher, that's it. You can now use the package, continue to the [ usage] ( #usage ) section.
49
53
@@ -54,11 +58,89 @@ this by adding the following line to your `config/app.php` file:
54
58
``` php
55
59
'providers' => [
56
60
...
57
- LaraCrafts \UrlShortener\UrlShortenerServiceProvider::class,
61
+ BinaryCats \UrlShortener\UrlShortenerServiceProvider::class,
58
62
...
59
63
],
60
64
```
61
65
66
+ ## Configuration
67
+
68
+ If you want to change the default configuration, you can publish it with:
69
+
70
+ ``` bash
71
+ php artisan vendor:publish --provider=BinaryCats\\ UrlShortener\\ UrlShortenerServiceProvider
72
+ ```
73
+
74
+ The package will expose the following config file:
75
+ ``` php
76
+ return [
77
+
78
+ 'default' => env('URL_SHORTENER_DRIVER', 'tiny_url'),
79
+
80
+ 'shorteners' => [
81
+
82
+ 'bit_ly' => [
83
+ 'driver' => 'bit_ly',
84
+ 'domain' => env('URL_SHORTENER_PREFIX', 'bit.ly'),
85
+ 'token' => env('URL_SHORTENER_API_TOKEN'),
86
+ ],
87
+
88
+ 'firebase' => [
89
+ 'driver' => 'firebase',
90
+ 'prefix' => env('URL_SHORTENER_PREFIX'),
91
+ 'token' => env('URL_SHORTENER_API_TOKEN'),
92
+ 'suffix' => env('URL_SHORTENER_STRATEGY', 'UNGUESSABLE'),
93
+ ],
94
+
95
+ 'is_gd' => [
96
+ 'driver' => 'is_gd',
97
+ 'base_uri' => 'https://is.gd',
98
+ 'statistics' => env('URL_SHORTENER_ANALYTICS', false),
99
+ ],
100
+
101
+ 'ouo_io' => [
102
+ 'driver' => 'ouo_io',
103
+ 'token' => env('URL_SHORTENER_API_TOKEN'),
104
+ ],
105
+
106
+ 'polr' => [
107
+ 'driver' => 'polr',
108
+ 'prefix' => env('URL_SHORTENER_PREFIX'),
109
+ 'token' => env('URL_SHORTENER_API_TOKEN'),
110
+ ],
111
+
112
+ 'shorte_st' => [
113
+ 'driver' => 'shorte_st',
114
+ 'token' => env('URL_SHORTENER_API_TOKEN'),
115
+ ],
116
+
117
+ 'tiny_url' => [
118
+ 'driver' => 'tiny_url',
119
+ ],
120
+
121
+ 'v_gd' => [
122
+ 'driver' => 'is_gd',
123
+ 'base_uri' => 'https://v.gd',
124
+ 'statistics' => env('URL_SHORTENER_ANALYTICS', false),
125
+ ],
126
+ ],
127
+ ];
128
+ ```
129
+
130
+ Below is the full list of ` .env ` values to configure:
131
+
132
+ ``` bash
133
+ # -------------------------
134
+ # Services: Url Shortener
135
+ #
136
+ # -------------------------
137
+ URL_SHORTENER_DRIVER=tiny_url
138
+ URL_SHORTENER_PREFIX=
139
+ URL_SHORTENER_API_TOKEN=
140
+ URL_SHORTENER_STRATEGY=
141
+ URL_SHORTENER_ANALYTICS=
142
+ ```
143
+
62
144
## Usage
63
145
The shortener can be retrieved from the container in two ways:
64
146
@@ -116,20 +198,21 @@ You can change the default driver by setting `URL_SHORTENER_DRIVER={driver}` in
116
198
config file and changing it directly.
117
199
118
200
### Adding your own drivers
119
- Much like Laravel's [ core components] ( https://laravel.com/docs/5.0/extending#managers-and-factories ) , you can add your
120
- own drivers for this package. You can do this by adding the following code to a central place in your application
121
- (preferably a service provider).
201
+ Much like all of Laravel, you can add your own drivers for this package.
202
+ You can do this by adding the following code to ` boot ` method of your ` AppServiceProvider ` .
122
203
123
204
``` php
124
- public function boot(ShortenerManager $shorteners)
205
+ use BinaryCats\UrlShortener\UrlShortenerManager;
206
+
207
+ public function boot(UrlShortenerManager $shorteners)
125
208
{
126
- $shorteners->extend('my_driver ', function ($app, $config) {
127
- // Return your driver instance here
209
+ $shorteners->extend('local ', function ($app, $config) {
210
+ return new LocalUrlShortener($app, $config);
128
211
});
129
212
}
130
213
```
131
214
132
- Once you have registered your driver you can call it like any other driver.
215
+ Once you have registered your driver you can call it just like any other driver.
133
216
134
217
If you wrote a custom driver that others might find useful (such as a public online shortener service), please consider
135
218
adding it to the package via a pull request.
@@ -165,7 +248,7 @@ Variable | Description
165
248
166
249
This driver runs on Firebase's API. The API requires an access token, a URI prefix and a suffix. You can access these
167
250
information on you firebase console. The token accessible under the project settings as "Web API Key" and the prefixes
168
- can be defined and accessed under the Dynamic Links menu.
251
+ can be defined and accessed under the Dynamic Links menu.
169
252
170
253
The suffix can have the value ` SHORT ` or ` UNGUESSABLE ` .
171
254
@@ -194,7 +277,7 @@ Variable | Description
194
277
This driver uses the Ouo.io API and requires an access token. The API allows for URL monetization via advertisements and
195
278
provides analytics via its dashboard.
196
279
197
- Variable | Description
280
+ Variable | Description
198
281
--------------------------|----------------------
199
282
` URL_SHORTENER_API_TOKEN ` | Your Ouo.io API token
200
283
@@ -234,6 +317,9 @@ find the author emails in the [composer.json](composer.json).
234
317
Please see [ CONTRIBUTING] ( CONTRIBUTING.md ) for details.
235
318
236
319
## Credits
320
+
321
+ This is a port from the original [ LaraCraft's Url Shortener] ( https://github.com/BinaryCats/laravel-url-shortener ) .
322
+
237
323
- [ Choraimy Kroonstuiver] ( https://github.com/axlon )
238
324
- [ László Görög] ( https://github.com/nerg4l )
239
325
- [ All Contributors] ( ../../contributors )
0 commit comments