1. Go to this page and download the library: Download glueful/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/ */
glueful / users example snippets
use Glueful\Auth\Contracts\UserProviderInterface;
use Glueful\Extensions\Users\Repositories\UserRepository;
// Resolve the identity provider through the CORE contract (never the concrete class)
$provider = container()->get(UserProviderInterface::class);
// Verify credentials — returns a canonical UserIdentity, or null on failure
$identity = $provider->verifyCredentials('[email protected]', 'secret');
if ($identity !== null) {
echo $identity->uuid();
echo $identity->email();
}
// Look up without credentials
$byUuid = $provider->findByUuid('<USER_UUID>');
$byLogin = $provider->findByLogin('[email protected]'); // email or username
// Create a user via the repository
$repo = container()->get(UserRepository::class);
$uuid = $repo->create([
'username' => 'jdoe',
'email' => '[email protected]',
'password' => 'secret',
]);
use Glueful\Extensions\Users\Repositories\UserRepository;
use Glueful\Database\Connection;
$repo = container()->get(UserRepository::class);
// Create a user AND its profile atomically
$uuid = container()->get(Connection::class)->transaction(function () use ($repo) {
$uuid = $repo->create([
'username' => 'jdoe',
'email' => '[email protected]',
'password' => 'secret',
]);
// Creates the profile row on first call
$repo->updateProfile($uuid, [
'first_name' => 'Jane',
'last_name' => 'Doe',
]);
return $uuid;
});
// Read a single profile / bulk-read (avoids N+1)
$profile = $repo->getProfile($uuid); // ['first_name','last_name','photo_uuid','photo_url']
$profiles = $repo->getProfilesForUsers([$uuid, '…']); // keyed by user_uuid
'profile_fields' => [
'me' => ['first_name', 'last_name', 'photo_url', 'phone'], // exposed to self
'users' => ['first_name', 'last_name', 'photo_url'], // not to others
],