Quicktips

There are times, often in tests or upgrade paths, where we want to programmatically install a module. Here's how:

\Drupal::service('module_installer')->install(['workspace']);

Place this code within .htaccess underneath `RewriteEngine on`.

RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

This is especially useful in kernel tests.

$node = Node::create([
  'type' => 'article',
  'title' => 'Example Node'
]);
$node->save()