The forum module is a core module that was rewritten for drupal 8. In this snippet I show you how to create forum topics programmatically.

use Drupal\node\Entity\Node;

    $node = Node::create(array(
      'type' => 'forum',
      'title' => $title,
      'langcode' => 'nl',
      'uid' => $uid,
      'status' => 1,
      'taxonomy_forums' => array(2), // The term id of your forum should be here!


Saved you some valuable time?

Donate and get more free time-saving code on this website in the future.