Download the PHP package dirape/token without Composer
On this page you can find all versions of the php package dirape/token. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package token
Laravel Token
Laravel unique Token Generator
Installation
Require this package, with Composer, in the root directory of your project.
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.
If you want you can use the facade. Add the reference in config/app.php
to your aliases array.
Documentation
★ New Token Trait ★
setup in model
To use new trait token you need to do some changes in the model that contain the token column.
One Column Token
One token Trait allow you to generate token for one columns in the table
- To use one column token you need to add
use DirapeToken;
in the model . - In database we use default column called
dt_token
to replace with your column name addprotected $DT_Column='column_name';
in the model . - Token settings are set by default to this value
['type' => DT_Unique, 'size' => 40, 'special_chr' => false]
to replace with your custom settings addprotected $DT_settings=['type'=>DT_Unique,'size'=>60,'special_chr'=>false];
in the model . -
you should know that we use custom constants for our token type
- after preparing the model to use our trait token in your code you can set the token with your custom column and settings like this
-
you can use your custom settings in
setToken();
function like this -
you can set your custom column in the function
-
To get model query with token you can use
WithToken()
. - To get model query with no tokens you can use flag
false
inWithToken()
Multi Column Token
Multi token allow you to generate tokens for multi columns in the same table
- To use multi column token you need to add
use DirapeMultiToken;
in the model . - Columns settings are not set by default so you need to make your custom settings in the model
-
you should know that we use custom constants for our token type
- after preparing the model to use our trait multi token in your code you can set the tokens with only one function
★ The old way ★
Generate unique token
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.
Generate unique string token
generate unique strings token with the same signature of unique token with function UniqueString($table_name,$column_name,$size)
.
Generate unique integer token
generate unique integers token with the same signature of unique token with function UniqueNumber($table_name,$column_name,$size)
.
Generate random token
generate random token with function Random($size)
and $size
is the size of token length.
Generate random integer token
generate random integer token with function RandomNumber($size)
and $size
is the size of token length.
Generate random string token
generate random string token with function RandomString($size)
and $size
is the size of token length.
Special Characters
use true
to allow special characters in your token !@#$%^&*()
in all functions just like Random($size,true)
.
Examples
Here you can see an example of just how simple this package is to use.
Unique Token
Random Token (not unique)
License
Mustafa Khaled