SDK PHP v3.x

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.

searchRoles #

Search for security roles, optionally returning only the roles giving access to the provided controller names.

searchRoles(filters, [options], callback) #

Arguments Type Description
filters JSON Object Optionally contains a "controllers" array listing the controller names used to filter searched roles
options JSON Object Optional parameters
callback function Callback handling the response

Filters #

Filter Type Description Default
controllers array retrieve only roles allowing access to the provided names []

Options #

Option Type Description Default
from number Starting offset 0
queuable boolean Make this request queuable or not true
size number Number of hits to return per page 10

Callback Response #

Return a JSON Object

Usage #

Copied to clipboard!
use \Kuzzle\Kuzzle;
use \Kuzzle\Security\Role;
use \Kuzzle\Util\RolesSearchResult;
// optional: retrieve only roles allowing access to the
// provided controller names
$filters = [
  'controllers' => [
// optional: result pagination configuration
$options = [
  'size' => 10,
  'from' => 0
$kuzzle = new Kuzzle('localhost');
$security = $kuzzle->security();
try {
  $result = $security->searchRoles($filters, $options);
  // $result instanceof RolesSearchResult
  foreach($result->getRoles() as $role) {
    // $role instanceof Role
catch (ErrorException $e) {

Callback response:

Copied to clipboard!
  "total": 124,
  "roles": [
    // array of Role