@@ -13,7 +13,6 @@ Powerful URL shortening tools in Laravel
13
13
- [ Requirements] ( #requirements )
14
14
- [ Laravel 5.5+] ( #laravel-55 )
15
15
- [ Laravel 5.1-5.4] ( #laravel-51-54 )
16
- - [ Lumen] ( #lumen )
17
16
- [ Usage] ( #usage )
18
17
- [ Changing the driver] ( #changing-the-driver )
19
18
- [ Adding your own drivers] ( #adding-your-own-drivers )
@@ -43,7 +42,7 @@ composer require laracrafts/laravel-url-shortener
43
42
This package has the following requirements:
44
43
45
44
- PHP 7.1 or higher
46
- - Laravel (or Lumen) 5.1 or higher
45
+ - Laravel 5.1 or higher
47
46
48
47
### Laravel 5.5+
49
48
If you use Laravel 5.5 or higher, that's it. You can now use the package, continue to the [ usage] ( #usage ) section.
@@ -60,21 +59,12 @@ this by adding the following line to your `config/app.php` file:
60
59
],
61
60
```
62
61
63
- ### Lumen
64
- If you're using Lumen, register the package's service provider by adding the following line to your ` bootstrap/app.php `
65
- file:
66
-
67
- ``` php
68
- $app->register(LaraCrafts\UrlShortener\UrlShortenerServiceProvider::class);
69
- ```
70
-
71
62
## Usage
72
63
The shortener can be retrieved from the container in two ways:
73
64
74
65
``` php
75
- // This works in both Laravel and Lumen
76
66
$shortener = app('url.shortener');
77
- // This only works in Laravel 5.2+
67
+ // or...
78
68
$shortener = url()->shortener();
79
69
```
80
70
@@ -88,13 +78,13 @@ $shortener->shorten(...);
88
78
$shortener->shortenAsync(...);
89
79
90
80
// You can also call shortening from Laravel's url component directly
91
- app(' url' )->shorten(...);
81
+ url( )->shorten(...);
92
82
93
83
// or...
94
- url( )->shorten(...);
84
+ app('url' )->shorten(...);
95
85
96
86
// or even...
97
- UrlShortener:: shorten(...);
87
+ app('url.shortener')-> shorten(...);
98
88
```
99
89
100
90
This package relies on Guzzle's promise library for its asynchronous shortening, read their
@@ -131,9 +121,12 @@ own drivers for this package. You can do this by adding the following code to a
131
121
(preferably a service provider).
132
122
133
123
``` php
134
- UrlShortener::extend('my_driver', function ($app, $config) {
135
- // Return your driver instance here
136
- });
124
+ public function boot(ShortenerManager $shorteners)
125
+ {
126
+ $shorteners->extend('my_driver', function ($app, $config) {
127
+ // Return your driver instance here
128
+ });
129
+ }
137
130
```
138
131
139
132
Once you have registered your driver you can call it like any other driver.
0 commit comments