SDK
SDK PHP v3.x
1

You are currently looking at the documentation of a previous version of Kuzzle. We strongly recommend that you use the latest version. You can also use the version selector in the top menu.

Constructors #

Instantiates a new User object, which is a representation of a Kuzzle user and is linked to a security Profile. #

User(Security, id, content, [meta]) #

ArgumentsTypeDescription
SecuritySecurityAn instantiated Security object
idstringUnique user identifier
contentJSON ObjectUser content
metaJSON ObjectUser metadata

Note: this constructor won't make any call to Kuzzle.


Properties #

Property nameTypeDescriptionget/set
contentJSON objectRaw user contentget
idstringUnique profile identifierget
metaJSON objectUser metadataget

Return Value #

Returns the User object.

Usage #

<?php
use \Kuzzle\Kuzzle;
use \Kuzzle\Security\User;
$kuid = 'myUser';
$userDefinition = [
  // A "profileIds" field is required to bind a user to an existing profile
  'profileIds' => ['myProfile'],
  // The "local" authentication strategy requires a password
  'password' => 'secret',
  'firstname' => 'John',
  'lastname' => 'Doe'
];
$kuzzle = new Kuzzle('localhost');
$security = $kuzzle->security();
// Using the Security factory
$user = $security->user($kuid, $userDefinition);
// Or directly with the constructor:
$user = new User($security, $kuid, $userDefinition);