Drupal - Create content programmatically
Here's a simple example of creating a node in Drupal 8.
$data = [
'type' => 'article',
'title' => 'My new title',
'uid' => 1
];
$node = Drupal::entityTypeManager()
->getStorage('node')
->create($data);
$node->save();
Updated to remove deprecated function as per comments from @mradcliffe. Thanks!
FYI, for testing out little snippets of code like this, the drush core-cli
command works great. See: http://www.drushcommands.com/drush-7x/core/core-cli