Adding multiple taxonomy terms to a node via code I've been editing nodes in code (Drupal 8) like so:

$node = \Drupal\node\Entity\Node::load($nid);
$node-&gt;body-&gt;value = $body;
$node-&gt;title-&gt;value = $title;
$node-&gt;taxonomy_field-&gt;target_id = $value;


If the 'taxonomy_field' entity reference supports multiple terms, how do place them in the $node object? I have tried at least a dozen ways I found on other threads, but none worked. Either errors were thrown, of the code just silently failed.
The object orientated way would be to use appendItem() from FieldItemList:

$node-&gt;field_tags-&gt;appendItem([target_id =&gt; '1']);


But as the field object provides an array interface you can add items to the field the same way as in a php array:

$node-&gt;field_tags[] = '2';