Skip to content

Commit 0cb882a

Browse files
committed
Replaced the original namespace
1 parent aa0fd59 commit 0cb882a

37 files changed

+253
-126
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## [v8.0.0](https://github.com/binary-cats/laravel-url-shortener/releases/tag/v8.0.0) (2020-10-10)
4+
- Fork of the original project
5+
- Replaced namespace with BinaryCats
6+
- Upgraded composer denpdencies
7+
38
## [v0.3.2](https://github.com/LaraCrafts/laravel-url-shortener/releases/tag/v0.3.2) (2019-09-12)
49
- Fix shorten function not being accessible from UrlGenerator and UrlShortenerManager
510

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Contributing
2-
Contributions are **welcome** and will be fully **credited**.
2+
Contributions are **welcome** and will be fully **credited**.
33

44
Please read the following contribution guide before creating an issue or a pull request.
55

README.md

Lines changed: 105 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
# laravel-url-shortener
2-
Powerful URL shortening tools in Laravel
1+
# Url Shortener for Laravel
2+
Powerful URL shortening tools for your Laravel
33

44
<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>
109
</p>
1110

1211
- [Installation](#installation)
1312
- [Requirements](#requirements)
13+
- [Laravel 8+](#laravel-8)
1414
- [Laravel 5.5+](#laravel-55)
1515
- [Laravel 5.1-5.4](#laravel-51-54)
16+
- [Configuration](#configuration)
1617
- [Usage](#usage)
1718
- [Changing the driver](#changing-the-driver)
1819
- [Adding your own drivers](#adding-your-own-drivers)
@@ -30,12 +31,12 @@ Powerful URL shortening tools in Laravel
3031
- [Contributing](#contributing)
3132
- [Credits](#credits)
3233
- [License](#license)
33-
34+
3435
## Installation
3536
You can easily install this package using Composer, by running the following command:
3637

3738
```bash
38-
composer require laracrafts/laravel-url-shortener
39+
composer require binary-cats/laravel-url-shortener
3940
```
4041

4142
### Requirements
@@ -44,6 +45,9 @@ This package has the following requirements:
4445
- PHP 7.1 or higher
4546
- Laravel 5.1 or higher
4647

48+
### Laravel 8+
49+
If you use Laravel 8 you must have PHP 7.3 or higher (which is a root laravel requirment)
50+
4751
### Laravel 5.5+
4852
If you use Laravel 5.5 or higher, that's it. You can now use the package, continue to the [usage](#usage) section.
4953

@@ -54,11 +58,89 @@ this by adding the following line to your `config/app.php` file:
5458
```php
5559
'providers' => [
5660
...
57-
LaraCrafts\UrlShortener\UrlShortenerServiceProvider::class,
61+
BinaryCats\UrlShortener\UrlShortenerServiceProvider::class,
5862
...
5963
],
6064
```
6165

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+
62144
## Usage
63145
The shortener can be retrieved from the container in two ways:
64146

@@ -116,20 +198,21 @@ You can change the default driver by setting `URL_SHORTENER_DRIVER={driver}` in
116198
config file and changing it directly.
117199

118200
### 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`.
122203

123204
```php
124-
public function boot(ShortenerManager $shorteners)
205+
use BinaryCats\UrlShortener\UrlShortenerManager;
206+
207+
public function boot(UrlShortenerManager $shorteners)
125208
{
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);
128211
});
129212
}
130213
```
131214

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.
133216

134217
If you wrote a custom driver that others might find useful (such as a public online shortener service), please consider
135218
adding it to the package via a pull request.
@@ -165,7 +248,7 @@ Variable | Description
165248

166249
This driver runs on Firebase's API. The API requires an access token, a URI prefix and a suffix. You can access these
167250
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.
169252

170253
The suffix can have the value `SHORT` or `UNGUESSABLE`.
171254

@@ -194,7 +277,7 @@ Variable | Description
194277
This driver uses the Ouo.io API and requires an access token. The API allows for URL monetization via advertisements and
195278
provides analytics via its dashboard.
196279

197-
Variable | Description
280+
Variable | Description
198281
--------------------------|----------------------
199282
`URL_SHORTENER_API_TOKEN` | Your Ouo.io API token
200283

@@ -234,6 +317,9 @@ find the author emails in the [composer.json](composer.json).
234317
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
235318

236319
## Credits
320+
321+
This is a port from the original [LaraCraft's Url Shortener](https://github.com/BinaryCats/laravel-url-shortener).
322+
237323
- [Choraimy Kroonstuiver](https://github.com/axlon)
238324
- [László Görög](https://github.com/nerg4l)
239325
- [All Contributors](../../contributors)

composer.json

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
{
2-
"name": "laracrafts/laravel-url-shortener",
2+
"name": "binary-cats/laravel-url-shortener",
33
"description": "Powerful URL shortening tools in Laravel",
44
"keywords": [
5+
"binary-cats",
6+
"bit.ly",
57
"laravel",
68
"lumen",
7-
"url",
8-
"shortening",
9+
"shorte.st",
910
"shortener",
10-
"bit.ly",
11+
"shortening",
1112
"tinyURL",
12-
"shorte.st"
13+
"url"
1314
],
1415
"type": "library",
1516
"license": "MIT",
@@ -21,40 +22,52 @@
2122
{
2223
"name": "László Görög",
2324
"email": "[email protected]"
24-
}
25+
},
26+
{
27+
"name": "Cyrill Kalita",
28+
"homepage": "https://github.com/cyrillkalita"
29+
},
2530
],
2631
"require": {
27-
"php": "^7.1",
28-
"guzzlehttp/guzzle": "^6.2",
32+
"php": ">=5.6.0",
33+
"guzzlehttp/guzzle": "^6.2||^7.0",
2934
"guzzlehttp/promises": "^1.0",
3035
"guzzlehttp/psr7": "^1.4",
31-
"illuminate/support": "^5.1 || ^6.0 || ^7.0",
36+
"illuminate/support": "^5.1 || ^6.0 || ^7.0 || ^8.0",
3237
"psr/http-message": "^1.0"
3338
},
3439
"require-dev": {
35-
"illuminate/routing": "^5.1 || ^6.0 || ^7.0",
36-
"phpunit/phpunit": "^7.0"
40+
"illuminate/routing": "^5.1 || ^6.0 || ^7.0 || ^8.0",
41+
"phpunit/phpunit": "^7.0|^8.0|^9.0"
3742
},
3843
"autoload": {
3944
"psr-4": {
40-
"LaraCrafts\\UrlShortener\\": "src/"
45+
"BinaryCats\\UrlShortener\\": "src/"
4146
}
4247
},
4348
"autoload-dev": {
4449
"psr-4": {
45-
"LaraCrafts\\UrlShortener\\Tests\\": "tests/"
50+
"BinaryCats\\UrlShortener\\Tests\\": "tests/"
4651
}
4752
},
4853
"config": {
4954
"sort-packages": true
5055
},
5156
"scripts": {
52-
"tests": "./vendor/bin/phpunit --colors=always"
57+
"test": "vendor/bin/phpunit --color=always",
58+
"check": [
59+
"php-cs-fixer fix --ansi --dry-run --diff .",
60+
"phpcs --report-width=200 --report-summary --report-full src/ tests/ --standard=PSR2 -n",
61+
"phpmd src/,tests/ text ./phpmd.xml.dist"
62+
],
63+
"fix": [
64+
"php-cs-fixer fix --ansi ."
65+
]
5366
},
5467
"extra": {
5568
"laravel": {
5669
"providers": [
57-
"\\LaraCrafts\\UrlShortener\\UrlShortenerServiceProvider"
70+
"\\BinaryCats\\UrlShortener\\UrlShortenerServiceProvider"
5871
]
5972
}
6073
}

phpmd.xml.dist

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<ruleset
3+
name="ProxyManager rules"
4+
xmlns="http://pmd.sf.net/ruleset/1.0.0"
5+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6+
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
7+
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd"
8+
>
9+
<rule ref="rulesets/codesize.xml"/>
10+
<rule ref="rulesets/unusedcode.xml"/>
11+
<rule ref="rulesets/design.xml">
12+
<!-- eval is needed to generate runtime classes -->
13+
<exclude name="EvalExpression"/>
14+
</rule>
15+
<rule ref="rulesets/naming.xml">
16+
<exclude name="LongVariable"/>
17+
</rule>
18+
<rule ref="rulesets/naming.xml/LongVariable">
19+
<properties>
20+
<property name="minimum">40</property>
21+
</properties>
22+
</rule>
23+
</ruleset>

src/Contracts/AsyncShortener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace LaraCrafts\UrlShortener\Contracts;
3+
namespace BinaryCats\UrlShortener\Contracts;
44

55
interface AsyncShortener extends Shortener
66
{

src/Contracts/Factory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<?php
22

3-
namespace LaraCrafts\UrlShortener\Contracts;
3+
namespace BinaryCats\UrlShortener\Contracts;
44

55
interface Factory
66
{
77
/**
88
* Get a shortener instance.
99
*
1010
* @param string|null $name
11-
* @return \LaraCrafts\UrlShortener\Contracts\Shortener
11+
* @return \BinaryCats\UrlShortener\Contracts\Shortener
1212
*/
1313
public function shortener(string $name = null);
1414
}

src/Contracts/Shortener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace LaraCrafts\UrlShortener\Contracts;
3+
namespace BinaryCats\UrlShortener\Contracts;
44

55
interface Shortener
66
{

src/Http/BitLyShortener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace LaraCrafts\UrlShortener\Http;
3+
namespace BinaryCats\UrlShortener\Http;
44

55
use GuzzleHttp\ClientInterface;
66
use function GuzzleHttp\json_decode;

src/Http/FirebaseShortener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace LaraCrafts\UrlShortener\Http;
3+
namespace BinaryCats\UrlShortener\Http;
44

55
use GuzzleHttp\ClientInterface;
66
use function GuzzleHttp\json_decode;

src/Http/IsGdShortener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace LaraCrafts\UrlShortener\Http;
3+
namespace BinaryCats\UrlShortener\Http;
44

55
use GuzzleHttp\ClientInterface;
66
use GuzzleHttp\Psr7\Request;

src/Http/OuoIoShortener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace LaraCrafts\UrlShortener\Http;
3+
namespace BinaryCats\UrlShortener\Http;
44

55
use GuzzleHttp\ClientInterface;
66
use GuzzleHttp\Psr7\Request;

src/Http/PolrShortener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace LaraCrafts\UrlShortener\Http;
3+
namespace BinaryCats\UrlShortener\Http;
44

55
use GuzzleHttp\ClientInterface;
66
use function GuzzleHttp\json_decode;

0 commit comments

Comments
 (0)