-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add support of Laravel 5.5. Update namespace
- Loading branch information
Anton Komarev
authored
Sep 9, 2017
1 parent
b3bd356
commit 4fee069
Showing
14 changed files
with
128 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ sudo: false | |
php: | ||
- 7.0 | ||
- 7.1 | ||
- 7.2 | ||
|
||
env: | ||
global: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
![cog-laravel-optimus-3](https://cloud.githubusercontent.com/assets/1849174/21738350/6c08b624-d494-11e6-9895-94e7d5f39010.png) | ||
![cog-laravel-optimus](https://user-images.githubusercontent.com/1849174/28744713-5b28fffa-746f-11e7-8ca2-0e2a612bc19c.png) | ||
|
||
<p align="center"> | ||
<a href="https://travis-ci.org/cybercog/laravel-optimus"><img src="https://img.shields.io/travis/cybercog/laravel-optimus/master.svg?style=flat-square" alt="Build Status"></a> | ||
|
@@ -11,11 +11,30 @@ | |
|
||
Laravel wrapper for the [Optimus Library](https://github.com/jenssegers/optimus) by [Jens Segers](https://github.com/jenssegers) with multiple connections support. Optimus is a small open-source library that generates short, unique, non-sequential ids from numbers. With this library, you can transform your internal id's to obfuscated integers based on Knuth's integer hash. It is similar to Hashids, but will generate integers instead of random strings. It is also super fast. | ||
|
||
## Contents | ||
|
||
- [Features](#features) | ||
- [Installation](#installation) | ||
- [Configuration](#configuration) | ||
- [Usage](#usage) | ||
- [Change log](#change-log) | ||
- [Upgrading](#upgrading) | ||
- [Contributing](#contributing) | ||
- [Testing](#testing) | ||
- [Security](#security) | ||
- [Credits](#credits) | ||
- [Alternatives](#alternatives) | ||
- [License](#license) | ||
- [About CyberCog](#about-cybercog) | ||
|
||
## Features | ||
|
||
- Designed to work with Laravel Eloquent models. | ||
- Configurable multiple connections support. | ||
- Dependency Injection ready. | ||
- Includes Facade. | ||
- Following PHP Standard Recommendations: | ||
- [PSR-1 (Basic Coding Standard)](http://www.php-fig.org/psr/psr-1/). | ||
- [PSR-2 (Coding Style Guide)](http://www.php-fig.org/psr/psr-2/). | ||
- [PSR-4 (Autoloading Standard)](http://www.php-fig.org/psr/psr-4/). | ||
- Covered with unit tests. | ||
|
@@ -28,19 +47,23 @@ First, pull in the package through Composer. | |
$ composer require cybercog/laravel-optimus | ||
``` | ||
|
||
And then include the service provider within `app/config/app.php`. | ||
**If you are using Laravel 5.5 you can skip register package part.** | ||
|
||
#### Register package on Laravel 5.4 and lower | ||
|
||
Include the service provider within `app/config/app.php`. | ||
|
||
```php | ||
'providers' => [ | ||
Cog\Optimus\Providers\OptimusServiceProvider::class, | ||
Cog\Laravel\Optimus\Providers\OptimusServiceProvider::class, | ||
], | ||
``` | ||
|
||
If you want you can use the [facade](http://laravel.com/docs/facades). Add the reference in `config/app.php` to your aliases array. | ||
|
||
```php | ||
'aliases' => [ | ||
'Optimus' => Cog\Optimus\Facades\Optimus::class, | ||
'Optimus' => Cog\Laravel\Optimus\Facades\Optimus::class, | ||
], | ||
``` | ||
|
||
|
@@ -49,7 +72,7 @@ If you want you can use the [facade](http://laravel.com/docs/facades). Add the r | |
Laravel Optimus requires connection configuration. To get started, you'll need to publish config file: | ||
|
||
```sh | ||
$ php artisan vendor:publish --provider="Cog\Optimus\Providers\OptimusServiceProvider" --tag="config" | ||
$ php artisan vendor:publish --provider="Cog\Laravel\Optimus\Providers\OptimusServiceProvider" --tag="config" | ||
``` | ||
|
||
This will create a `config/optimus.php` file in your app that you can modify to set your configuration. Also, make sure you check for changes to the original config file in this package between releases. | ||
|
@@ -99,21 +122,21 @@ Here you can see an example of just how simple this package is to use. Out of th | |
#### Encode ID | ||
|
||
```php | ||
Cog\Optimus\Facades\Optimus::encode(20); // 1535832388 | ||
Cog\Laravel\Optimus\Facades\Optimus::encode(20); // 1535832388 | ||
``` | ||
|
||
#### Decode ID | ||
|
||
```php | ||
Cog\Optimus\Facades\Optimus::decode(1535832388); // 20 | ||
Cog\Laravel\Optimus\Facades\Optimus::decode(1535832388); // 20 | ||
``` | ||
|
||
#### Alter Optimus connection | ||
|
||
The Optimus manager will behave like it is a `Jenssegers\Optimus\Optimus`. If you want to call specific connections, you can do that with the connection method: | ||
|
||
```php | ||
use Cog\Optimus\Facades\Optimus; | ||
use Cog\Laravel\Optimus\Facades\Optimus; | ||
|
||
// Writing this… | ||
Optimus::connection('main')->encode($id); | ||
|
@@ -136,7 +159,7 @@ Optimus::setDefaultConnection('alternative'); // The default is now alternative. | |
If you prefer to use dependency injection over facades like me, then you can inject the manager: | ||
|
||
```php | ||
use Cog\Optimus\OptimusManager; | ||
use Cog\Laravel\Optimus\OptimusManager; | ||
|
||
class Foo | ||
{ | ||
|
@@ -156,6 +179,18 @@ class Foo | |
app()->make('Foo')->bar(20); | ||
``` | ||
|
||
## Changelog | ||
|
||
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. | ||
|
||
## Upgrading | ||
|
||
Please see [UPGRADING](UPGRADING.md) for detailed upgrade instructions. | ||
|
||
## Contributing | ||
|
||
Please see [CONTRIBUTING](CONTRIBUTING.md) for details. | ||
|
||
## Testing | ||
|
||
Run the tests with: | ||
|
@@ -164,10 +199,6 @@ Run the tests with: | |
$ vendor/bin/phpunit | ||
``` | ||
|
||
## Contributing | ||
|
||
Please see [CONTRIBUTING](CONTRIBUTING.md) for details. | ||
|
||
## Security | ||
|
||
If you discover any security related issues, please email [email protected] instead of using the issue tracker. | ||
|
@@ -184,12 +215,9 @@ Package was inspired by [Laravel Hashids](https://github.com/vinkla/laravel-hash | |
|
||
This package is a wrapper for [Optimus Library](https://github.com/jenssegers/optimus). | ||
|
||
## Changelog | ||
|
||
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. | ||
|
||
## Alternatives | ||
|
||
- [vinkla/laravel-hashids](https://github.com/vinkla/laravel-hashids) | ||
- [propaganistas/laravel-fakeid](https://github.com/Propaganistas/Laravel-FakeId) | ||
|
||
*Feel free to add more alternatives as Pull Request.* | ||
|
@@ -202,4 +230,7 @@ Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed re | |
|
||
[CyberCog](http://www.cybercog.ru) is a Social Unity of enthusiasts. Research best solutions in product & software development is our passion. | ||
|
||
- [Follow us on Twitter](https://twitter.com/cybercog) | ||
- [Read our articles on Medium](https://medium.com/cybercog) | ||
|
||
<a href="http://cybercog.ru"><img src="https://cloud.githubusercontent.com/assets/1849174/18418932/e9edb390-7860-11e6-8a43-aa3fad524664.png" alt="CyberCog"></a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.