// Get an array of term objects for the given vocabulary
$terms = Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadByProperties(['vid' => 'my_vocabulary_machine_name']);
if (!empty($terms)) {
foreach ($terms as $term) {
//Only return comments that "published" status.
if ($term->status->value == 1) {
// These assignments show how to
// get the term's id, name, and uuid.
$terms_array[] = [
'term_tid' => $term->id(),
'term_name' => $term->name->value,
'term_uuid' => $term->uuid->value,
];
}
}
}