Drupal is a content management system that allows you to create and manage website content in an organized way. One of the ways to create content in Drupal is by creating a node programmatically. A node is a fundamental building block of a Drupal website and represents a piece of content such as an article, a page, or a product.
To create a node programmatically in Drupal 8+, you will need to use the Drupal's Entity API, specifically the Node class. Here's an example of how you can create a basic node:
use Drupal\node\Entity\Node;
// Create a new node object.
$node = Node::create([
'type' => 'article',
'title' => 'My programmatically created node',
'body' => [
'value' => 'This is the body of my programmatically created node.',
'format' => 'full_html',
],
]);
// Save the node.
$node->save();