1. Go to this page and download the library: Download kylearch/ephemeral-users library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kylearch / ephemeral-users example snippets
use KyleArch\EphemeralUsers\Contracts\EphemeralUser as EphemeralUserContract;
use KyleArch\EphemeralUsers\Concerns\HasEphemeralState;
class User extends Authenticatable implements EphemeralUserContract
{
use HasEphemeralState;
// Your existing User model code...
}
// Create an ephemeral user instance
$ephemeralUser = User::ephemeral([
'id' => 'session-abc123',
'email' => '[email protected]',
'name' => 'Anonymous User',
]);
// Check if a user is ephemeral
if ($ephemeralUser->isEphemeral()) {
// Handle ephemeral user logic
}
// Get the ephemeral identifier
$identifier = $ephemeralUser->getEphemeralIdentifier(); // 'session-abc123'