How to create manually an Entry from command line I would like to migrate content from external source to my Section model. So I have to create Entries manually. Is there any better way to do this beside this snippet from the documentation:

$entry = new Entry();
$entry-&gt;sectionId = 10;
$entry-&gt;typeId = 1;
$entry-&gt;fieldLayoutId = $entry-&gt;getType()-&gt;fieldLayoutId;
$entry-&gt;authorId = 5;
$entry-&gt;enabled = true;
$entry-&gt;title = "Hello World!";
$entry-&gt;setFieldValues([
    'body' =&gt; "&lt;p&gt;I can’t believe I literally just called this “Hello World!”.&lt;/p&gt;",
]);
$success = Craft::$app-&gt;elements-&gt;saveElement($entry);
if (!$success) {
    Craft::error('Couldn’t save the entry "'.$entry-&gt;title.'"', __METHOD__);
}


reference: https://docs.craftcms.com/api/v3/craft-services-elements.html#saveElement()-detail

I am looking for a factory method, or a Builder to properly create the object. Using EntityController is not an option, because I would like to use it from CommandLine interface.
This is the best answer so far. Basically the easiest way is to use array, and map everything there. The saveElement function will the the rest. You can update fields, tags, categories, matrixTables etc. The given example is matrix-data only, but again the same logic could be used everywhere.

How to save Matrix data programmatically in Craft 3

The only missing point is the "merge" functionality but I guess it has to be done manually after using the toArray() function first