Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/charukiewicz/cakephp-hashids-lib
Implementation of the Hashids (hashids.org) library as a CakePHP 2.x Lib.
https://github.com/charukiewicz/cakephp-hashids-lib
Last synced: 1 day ago
JSON representation
Implementation of the Hashids (hashids.org) library as a CakePHP 2.x Lib.
- Host: GitHub
- URL: https://github.com/charukiewicz/cakephp-hashids-lib
- Owner: charukiewicz
- Created: 2015-06-29T16:08:39.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-07-20T17:13:24.000Z (over 9 years ago)
- Last Synced: 2023-08-10T07:13:46.901Z (over 1 year ago)
- Language: PHP
- Size: 133 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# cakephp-hashids-lib
[Hashids](http://www.hashids.org) Library for [CakePHP](http://cakephp.org/) 2.x
This is a modification of [FinalDevStudio's Hashids Component](https://github.com/FinalDevStudio/cakephp-hashids/) repackaged as a generic lib rather than a controller component. This allows for access to the Hashids library in other libs and models rather than just controllers. It also moves the configuration to your application's core.php file.
## Installation
First, grab **Hashids.php** and **HashGenerator.php** from http://www.hashids.org/php/ and put them in your app's **Vendor/Hashids** folder.
Next, put **HashidsUtility.php** into your **app/Lib** directory.
Finally, add the following to **Config/core.php**:
```php
Configure::write('Hashids', array(
'salt' => 'SALT_GOES_HERE', // Required
'min_hash_length' => 0, // Optional
'alphabet' => '', // Optional
));
```## Usage
You can now invoke the **HashidsUtility** anywhere in your application.
At the top of your file, add
```php
App::uses('HashidsUtility', 'Lib');
```Then in the body of your file, invoke the Hashids class
```php
$Hashids = new HashidsUtility();
```You can then make calls to the encode and decode methods through this object.
```php
$myVar = 1;$encodedVar = $Hashids->encode($myVar);
....
$decodedVar = $Hashids->decode($encodedVar);
```For complete documentation check out [hashids.org/php](http://hashids.org/php/).