Download the PHP package diarmuidie/niceid without Composer
On this page you can find all versions of the php package diarmuidie/niceid. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download diarmuidie/niceid
More information about diarmuidie/niceid
Files in diarmuidie/niceid
Package niceid
Short Description PHP library to generate short, non-sequential, URL-friendly hashes of incremental IDs. Similar to YouTube (https://www.youtube.com/watch?v=dQw4w9WgXcQ) and Bitly (http://bit.ly/1D0CAzd) URLs.
License MIT
Homepage http://github.com/diarmuidie/niceid
Informations about the package niceid
diarmuidie/niceid
PHP library to generate short, non-sequential, URL-friendly hashes of incremental IDs. Similar to YouTube https://www.youtube.com/watch?v=dQw4w9WgXcQ and Bitly http://bit.ly/1D0CAzd URLs.
Developed by Diarmuid.
Features
- Non-sequential IDs (i.e. difficult, but not impossible, to guess the next one).
- URL friendly.
- No external dependencies.
- PSR-4 compatible.
- Compatible with PHP >= 5.6
Installation
You can install NiceID through Composer:
Usage
Generate an ID from a int:
Notice that a secret is passed to the NiceID constructor. This secret is used to encode and decode the IDs. If the secret changes then IDs cannot be decoded.
Use the decode method to decode the NiceID back to an int.
You can also change the min length of the NiceID (Defaults to 5 if not specified):
To specify the characters to use in the encoded string use the setCharacters()
method.
The default character set is: 0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_
You can even specify a UTF-8 character set if you want:
To Do
- [x] Add library to packagist.
- [x] Setup Travis to run unit tests.
- [x] Better handle UTF-8 chars in character string.
- [x] 100% Code coverage for unit tests.
- [x] Refactor
BaseConvert::convert()
method. - [x] Handle
PHP_INT_MAX
overflow. - [ ] Implement BCMath support for integers larger than
PHP_INT_MAX
. - [x] Setup Drone.io to run unit tests.
Contributing
Feel free to contribute features, bug fixes or just helpful advice :smile:
- Fork this repo
- Create a feature branch
- Submit a PR ...
- Profit :sunglasses:
Changelog
See the CHANGELOG.md file.
Authors
License
The MIT License (MIT)
Copyright (c) 2015 Diarmuid
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.