How can I get all fields and values of a node at once? I know how to get a particular field (title field) of a node by following code:

$publications = \Drupal::entityManager()-&gt;getStorage('node')-&gt;load($node_id);
$title = $publications-&gt;getTitle(); 


But I need to get all fields and values in that particular node. I tried print_r($publications). Is there any way to get this?
This is how you can add all values in a custom array. The EntityManager class and the entity.manager service are deprecated; you should use the entity_type.manager service instead.

$publications = \Drupal::entityTypeManager()
  -&gt;getStorage('node')
  -&gt;load($node_id);

foreach ($publications-&gt;getFields() as $name =&gt; $field) {
  $myFields[$name] = $field-&gt;getString();
}

kint($myFields);


You need to improve this code because for some field types that can be different. 


For multi-value fields you use $field-&gt;getValue()
For entity reference fields, $field-&gt;entity-&gt;field_name-&gt;value