Skip to content

Commit 7d05b62

Browse files
committed
- Support Laravel 8
- Remove Laravel 5 & 6 support - Remove PHP >7.2 support
1 parent 46e1ba5 commit 7d05b62

File tree

9 files changed

+78
-58
lines changed

9 files changed

+78
-58
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/vendor
22
composer.phar
33
composer.lock
4-
.DS_Store
4+
.phpunit.result.cache
5+
.DS_Store
6+
.idea/*

.travis.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
language: php
22

33
php:
4-
- 5.6
5-
- 7.1
64
- 7.2
75
- 7.3
6+
- 7.4
87

98
before_script:
109
- curl -s http://getcomposer.org/installer | php
11-
- php composer.phar install --dev
10+
- php composer.phar install
1211

13-
script: php ./vendor/bin/phpunit
12+
script:
13+
- ./vendor/bin/phpcs --standard=phpcs.xml src
14+
- ./vendor/bin/phpstan --level=0 --memory-limit=-1 --no-progress analyse src

README.md

Lines changed: 12 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Hashids for Laravel 5
1+
# Hashids for Laravel
22

33
[![Latest Stable Version](https://poser.pugx.org/torann/hashids/v/stable.png)](https://packagist.org/packages/torann/hashids) [![Total Downloads](https://poser.pugx.org/torann/hashids/downloads.png)](https://packagist.org/packages/torann/hashids)
44

@@ -12,7 +12,6 @@ Generate hashes from numbers, like YouTube or Bitly. Use hashids when you do not
1212

1313
- [Hashids on Packagist](https://packagist.org/packages/torann/hashids)
1414
- [Hashids on GitHub](https://github.com/torann/laravel-hashids)
15-
- [Laravel 4 Installation](#user-content-laravel-4-installation)
1615

1716
### Composer
1817

@@ -22,41 +21,35 @@ From the command line run:
2221
$ composer require torann/hashids
2322
```
2423

25-
Once Hashids is installed you need to register the service provider with the application. Open up `config/app.php` and find the `providers` key.
24+
**Without Package Auto-Discovery**
25+
26+
Once Hashids is installed you need to register the service provider and facade with the application. Open up `config/app.php` and find the `providers` and `aliases` keys.
2627

2728
```php
2829
'providers' => [
2930
Torann\Hashids\HashidsServiceProvider::class,
3031
]
31-
```
3232

33-
> There is no need to add the Facade, the package will add it for you.
33+
'aliases' => [
34+
'Hashids' => Torann\Hashids\Facade\Hashids::class,
35+
]
36+
```
3437

3538
### Publish the configurations
3639

3740
Run this on the command line from the root of your project:
3841

39-
~~~
42+
```
4043
$ php artisan vendor:publish --provider="Torann\Hashids\HashidsServiceProvider"
41-
~~~
44+
```
4245

4346
A configuration file will be publish to `config/hashids.php`.
4447

45-
## Laravel 4 Installation
46-
47-
Add verison 1.0 of Hashids in your `composer.json` file.
48-
49-
~~~
50-
"torann/hashids": "1.0.*"
51-
~~~
52-
53-
And following the directions in the [README](https://github.com/Torann/laravel-hashids/tree/1.0.0) on version 1.0.
54-
5548
## Usage
5649

5750
Once you've followed all the steps and completed the installation you can use Hashids.
5851

59-
### Encodeing
52+
### Encoding
6053

6154
You can simply encode a single id:
6255

@@ -70,7 +63,7 @@ or multiple..
7063
Hashids::encode(1, 21, 12, 12, 666); // Returns MMtaUpSGhdA
7164
```
7265

73-
### Decodeing
66+
### Decoding
7467

7568
```php
7669
Hashids::decode(Ri7Bi);
@@ -94,25 +87,4 @@ array (size=5)
9487
4 => int 666
9588
```
9689

97-
## Changelog
98-
99-
**2.0.0**
100-
101-
- Upgraded to Laravel 5
102-
- Upgraded to Hashids 1.0.5
103-
104-
**1.0.0**
105-
106-
- Several public functions are renamed to be more appropriate:
107-
- Function `encrypt()` changed to `encode()`
108-
- Function `decrypt()` changed to `decode()`
109-
- Function `encryptHex()` changed to `encodeHex()`
110-
- Function `decryptHex()` changed to `decodeHex()`
111-
112-
Hashids was designed to encode integers, primary ids at most. Hashids is the wrong algorithm to encrypt sensitive data. So to encourage more appropriate use, `encrypt/decrypt` is being "downgraded" to `encode/decode`.
113-
114-
- Version tag added: `1.0`
115-
- `README.md` updated
116-
117-
11890
All credit for Hashids goes to Ivan Akimov (@ivanakimov), thanks to for making it!

composer.json

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,29 @@
1010
}
1111
],
1212
"require": {
13-
"php": ">=5.6",
14-
"illuminate/support": "~5.0|~6.0|~7.0",
15-
"hashids/hashids": "1.0.6"
13+
"php": "^7.2",
14+
"illuminate/support": "~7.0|~8.0",
15+
"hashids/hashids": "~4.0"
16+
},
17+
"require-dev": {
18+
"phpunit/phpunit": "^8.0",
19+
"mockery/mockery": "^1.3",
20+
"phpstan/phpstan": "^0.12.14",
21+
"squizlabs/php_codesniffer": "^3.5"
1622
},
1723
"autoload": {
1824
"psr-4": {
1925
"Torann\\Hashids\\": "src/Torann/Hashids"
2026
}
27+
},
28+
"extra": {
29+
"laravel": {
30+
"providers": [
31+
"Torann\\Hashids\\HashidsServiceProvider"
32+
],
33+
"aliases": {
34+
"Hashids": "Torann\\Hashids\\Facade\\Hashids"
35+
}
36+
}
2137
}
2238
}

phpcs.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="PSR2-package">
3+
<description>The PSR2 standard</description>
4+
5+
<!-- use preg_match https://github.com/squizlabs/PHP_CodeSniffer/issues/742#issuecomment-215250517 -->
6+
<exclude-pattern>/resources/</exclude-pattern>
7+
<exclude-pattern>/vendor/</exclude-pattern>
8+
<exclude-pattern>/_[a-zA-Z0-9\._]+\.php</exclude-pattern>
9+
<exclude-pattern>/\.[a-zA-Z0-9\._]+\.php</exclude-pattern>
10+
<exclude-pattern>\.git</exclude-pattern>
11+
12+
<!-- Include the whole PSR2 standard -->
13+
<rule ref="PSR2">
14+
<exclude name="PSR1.Methods.CamelCapsMethodName"/>
15+
<exclude name="PSR2.Files.EndFileNewline"/>
16+
<exclude name="PSR2.Methods.FunctionCallSignature.MultipleArguments"/>
17+
<exclude name="Squiz.ControlStructures.ControlSignature.SpaceAfterCloseBrace"/>
18+
</rule>
19+
20+
<!-- Lines can be longer -->
21+
<rule ref="Generic.Files.LineLength">
22+
<properties>
23+
<property name="lineLimit" value="9999"/>
24+
</properties>
25+
</rule>
26+
</ruleset>

phpstan.neon

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
parameters:
2+
excludes_analyse:
3+
- vendor
4+
- resources
5+
ignoreErrors:
6+
- '#Function config_path not found#'

phpunit.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
convertWarningsToExceptions="true"
99
processIsolation="false"
1010
stopOnFailure="false"
11-
syntaxCheck="false"
1211
>
1312
<testsuites>
1413
<testsuite name="Package Test Suite">

src/Torann/Hashids/Facade.php renamed to src/Torann/Hashids/Facade/Hashids.php

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

3-
namespace Torann\Hashids;
3+
namespace Torann\Hashids\Facade;
44

55
use Illuminate\Support\Facades\Facade as IlluminateFacade;
66

7-
class Facade extends IlluminateFacade
7+
class Hashids extends IlluminateFacade
88
{
99
/**
10-
* Get the registered component.
10+
* Get the registered name of the component.
1111
*
12-
* @return object
12+
* @return string
1313
*/
1414
protected static function getFacadeAccessor()
1515
{

src/Torann/Hashids/HashidsServiceProvider.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
<?php namespace Torann\Hashids;
1+
<?php
2+
3+
namespace Torann\Hashids;
24

35
use Hashids\Hashids;
46
use Illuminate\Support\Arr;
57
use Illuminate\Support\Str;
68
use Illuminate\Support\ServiceProvider;
7-
use Illuminate\Foundation\AliasLoader;
89

910
class HashidsServiceProvider extends ServiceProvider
1011
{
@@ -19,9 +20,6 @@ public function boot()
1920
$this->publishes([
2021
__DIR__ . '/../../config/hashids.php' => config_path('hashids.php'),
2122
]);
22-
23-
// Add 'Assets' facade alias
24-
AliasLoader::getInstance()->alias('Hashids', 'Torann\Hashids\Facade');
2523
}
2624
}
2725

0 commit comments

Comments
 (0)