Bootstrap from external script
For current version of drupal 8.x:

define('DRUPAL_DIR', '/usr/share/nginx/html');
use Drupal\Core\DrupalKernel;
use Symfony\Component\HttpFoundation\Request;
require_once DRUPAL_DIR . '/core/includes/database.inc';
require_once DRUPAL_DIR . '/core/includes/schema.inc';
// Specify relative path to the drupal root.
$autoloader = require_once DRUPAL_DIR . '/autoload.php';

$request = Request::createFromGlobals();

// Bootstrap drupal to different levels
$kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod');
$kernel-&gt;boot();
$kernel-&gt;prepareLegacyRequest($request);

$em = $kernel-&gt;getContainer()-&gt;get('entity.manager');

$entity = $em-&gt;getStorage('node')-&gt;create(
        array(
          'type' =&gt; "article",
          'title'=&gt; "test entity",
          'body' =&gt; "body body body",
        ));

$entity-&gt;save();