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])

Arguments Type Description
Security Security An instantiated Security object
id string Unique user identifier
content JSON Object User content
meta JSON Object User metadata

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


Properties

Property name Type Description get/set
content JSON object Raw user content get
id string Unique profile identifier get
meta JSON object User metadata get

Return Value

Returns the User object.

Usage

Copied to clipboard!

<?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);