jasny / invite-code
This package is abandoned and no longer maintained.
No replacement package was suggested.
Library for using invitation codes
v0.1.0
2020-08-26 10:16 UTC
Requires
- php: >=5.4.0
Requires (Dev)
- mikey179/vfsstream: 1.*
- phpunit/phpunit: 3.*
This package is auto-updated.
Last update: 2024-09-03 21:30:44 UTC
README
This library can be used for requiring invitation codes at registration. This is often the case when an application is in private beta phase.
Installation
This library is registred at packagist as jasny/invite-code and can be easily installed using composer.
composer require jasny/invite-code
Generation
To create 100 random invitation codes run the following on the command line
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']);