Create content programmatically
Here's a simple example of creating a node in Drupal 8.

$data = [
  'type' =&gt; 'article', 
  'title' =&gt; 'My new title', 
  'uid' =&gt; 1
];
$node = Drupal::entityTypeManager()
  -&gt;getStorage('node')
  -&gt;create($data);
$node-&gt;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