|
1 |
| -# laravel-token |
2 |
| -Generate unique Laravel Token |
| 1 | +# Laravel Token |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | +Laravel unique Token Generator |
| 6 | +```php |
| 7 | +// Generate unique Token From Database. |
| 8 | +$new_token = $token->Unique($table_name, $column_name, $size); |
| 9 | + |
| 10 | +``` |
| 11 | + |
| 12 | +## Installation |
| 13 | + |
| 14 | +Require this package, with [Composer](https://getcomposer.org/), in the root directory of your project. |
| 15 | + |
| 16 | +```bash |
| 17 | +$ composer require dirape/token |
| 18 | +``` |
| 19 | + |
| 20 | +Add the service provider to `config/app.php` in the `providers` array, or if you're using Laravel 5.5, this can be done via the automatic package discovery. |
| 21 | + |
| 22 | +```php |
| 23 | +Dirape\Token\TokenServiceProvider::class |
| 24 | +``` |
| 25 | + |
| 26 | +If you want you can use the [facade](http://laravel.com/docs/facades). Add the reference in `config/app.php` to your aliases array. |
| 27 | + |
| 28 | +```php |
| 29 | +'Token'=>\Dirape\Token\Facades\Facade::class |
| 30 | +``` |
| 31 | + |
| 32 | +## Documentation |
| 33 | + |
| 34 | +#### Generate unique token |
| 35 | + |
| 36 | +With this package you can generate unqiue token not repated in database just by using `unique($table_name,$column_name,$size)` Function `$table_name` is the table name in database , `$column_name` is the column name in the table, `$size` is token size. |
| 37 | + |
| 38 | + |
| 39 | +#### Generate unique string token |
| 40 | + |
| 41 | +generate unique strings token with the same signature of unique token with function `UniqueString($table_name,$column_name,$size)`. |
| 42 | + |
| 43 | + |
| 44 | +#### Generate unique integer token |
| 45 | + |
| 46 | +generate unique integers token with the same signature of unique token with function `UniqueNumber($table_name,$column_name,$size)`. |
| 47 | + |
| 48 | + |
| 49 | +#### Generate random token |
| 50 | +generate random token with function `Random($size)` and `$size` is the size of token length. |
| 51 | + |
| 52 | + |
| 53 | +#### Generate random integer token |
| 54 | +generate random integer token with function `RandomNumber($size)` and `$size` is the size of token length. |
| 55 | + |
| 56 | + |
| 57 | +#### Generate random string token |
| 58 | +generate random string token with function `RandomString($size)` and `$size` is the size of token length. |
| 59 | + |
| 60 | +#### Special Characters |
| 61 | + |
| 62 | +use `true` to allow special characters in your token `!@#$%^&*()` in all functions just like `Random($size,true)`. |
| 63 | + |
| 64 | +### Examples |
| 65 | + |
| 66 | +Here you can see an example of just how simple this package is to use. |
| 67 | +#### Unique Token |
| 68 | +```php |
| 69 | + |
| 70 | +// Generate unique token not rebeated in database table with column name |
| 71 | +Token::Unique($table_name, $column_name, 10 ); |
| 72 | +//Result: fCWih6TDAf |
| 73 | + |
| 74 | + |
| 75 | +// Generate unique integer token not rebeated in database table with column name |
| 76 | +Token::UniqueNumber($table_name, $column_name, 10 ); |
| 77 | +//Result: 9647307239 |
| 78 | + |
| 79 | + |
| 80 | +// Generate unique string token not rebeated in database table with column name |
| 81 | +Token::UniqueString($table_name, $column_name, 10 ); |
| 82 | +//Result: SOUjkyAyxC |
| 83 | + |
| 84 | + |
| 85 | +//You can use special characters just add "true" to the function |
| 86 | +Token::Unique($table_name, $column_name, 10,true ); |
| 87 | +//Result: H@klU$u^3z |
| 88 | +``` |
| 89 | + |
| 90 | +#### Random Token (not unique) |
| 91 | +```php |
| 92 | +$size=10; |
| 93 | +// Generate random token |
| 94 | +Token::Random($size); |
| 95 | + |
| 96 | +// Generate random integer token |
| 97 | +Token::RandomNumber($size); |
| 98 | + |
| 99 | +// Generate random string token |
| 100 | +Token::RandomString($size); |
| 101 | + |
| 102 | +//You can use special characters just add "true" to the function |
| 103 | +Token::Random($size,true); |
| 104 | + |
| 105 | +``` |
| 106 | + |
| 107 | +## License |
| 108 | + |
| 109 | +[MIT](LICENSE) © [Mustafa Khaled](https://github.com/Dirape) |
0 commit comments