library invite-code
Library for using invitation codes
jasny/invite-code
Library for using invitation codes
- Monday, February 2, 2015
- by jasny
- Repository
- 2 Watchers
- 12 Stars
- 375 Installations
- PHP
- 0 Dependents
- 0 Suggesters
- 0 Forks
- 1 Open issues
- 2 Versions
- 10 % Grown
Jasny Invite code
, (*1)
This library can be used for requiring invitation codes at registration. This is often the case when an application is in private beta phase., (*2)
Installation
This library is registred at packagist as jasny/invite-code and can be easily installed using composer., (*3)
composer require jasny/invite-code
Generation
To create 100 random invitation codes run the following on the command line, (*4)
mkdir invite-codes
cd invite-codes
for i in {1..100}; do
CODE=$(cat /dev/urandom | env LC_CTYPE=C tr -dc 'A-Z0-9' | fold -w 8 | head -n 1)
touch $CODE
echo $CODE
done
Usage
Jasny\InviteCode::setDir('invite-codes');
$invite = new Jasny\InviteCode($_POST['invite']);
if (!$invite->isValid()) {
echo "Invalid invite code";
exit();
}
if ($invite->isUsed()) {
echo "Invite code is already used";
exit();
}
$invite->useBy($_POST['name']);
dev-master
9999999-dev
Library for using invitation codes
Sources
Download
MIT
The Requires
The Development Requires