Skip to main content
edited title
Link
Pierre.Vriens
  • 36k
  • 40
  • 50
  • 182

How do Ito fix this error about the Node class not found?

deleted 91 characters in body
Source Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

I've installed Drupal 8, I've created a PHP file to read a XML file and insert some items, but I'm getting this error.

Fatal error: Uncaught Error: Class 'Drupal\node\Entity\Node' not found in C:\xampp\htdocs\drupal8\migracion.php:12 Stack trace: #0 {main} thrown in C:\xampp\htdocs\drupal8\migracion.php on line 12

This is the code I am using.

define('DRUPAL_DIR', __DIR__);
use \Drupal\Core\DrupalKernel;
use \Symfony\Component\HttpFoundation\Request;
use \Drupal\node\Entity\Node;
use \Drupal\file\Entity\File;
use \Drupal\pathauto\PathautoState;

$fileContentXML = file_get_contents(DRUPAL_DIR . "/sites/default/files/migration/data.xml");
$xml_file = simplexml_load_string($fileContentXML);
foreach ($xml_file->channel->item as $item) {
  $node = Node::create(['type' => 'article']);
  $nid = trim($item->nid);
  $node->set('nid', $nid);
  $node->set('uid', 1);
  $node->enforceIsNew();
  $node->save();
}

This is line 12 $node = Node::create(['type' => 'article']);

Do you have some idea howHow can iI fix this error?

I've installed Drupal 8, I've created a PHP file to read a XML file and insert some items, but I'm getting this error.

Fatal error: Uncaught Error: Class 'Drupal\node\Entity\Node' not found in C:\xampp\htdocs\drupal8\migracion.php:12 Stack trace: #0 {main} thrown in C:\xampp\htdocs\drupal8\migracion.php on line 12

This is the code I am using.

define('DRUPAL_DIR', __DIR__);
use \Drupal\Core\DrupalKernel;
use \Symfony\Component\HttpFoundation\Request;
use \Drupal\node\Entity\Node;
use \Drupal\file\Entity\File;
use \Drupal\pathauto\PathautoState;

$fileContentXML = file_get_contents(DRUPAL_DIR . "/sites/default/files/migration/data.xml");
$xml_file = simplexml_load_string($fileContentXML);
foreach ($xml_file->channel->item as $item) {
  $node = Node::create(['type' => 'article']);
  $nid = trim($item->nid);
  $node->set('nid', $nid);
  $node->set('uid', 1);
  $node->enforceIsNew();
  $node->save();
}

This is line 12 $node = Node::create(['type' => 'article']);

Do you have some idea how can i fix this error?

I've installed Drupal 8, I've created a PHP file to read a XML file and insert some items, but I'm getting this error.

Fatal error: Uncaught Error: Class 'Drupal\node\Entity\Node' not found in C:\xampp\htdocs\drupal8\migracion.php:12 Stack trace: #0 {main} thrown in C:\xampp\htdocs\drupal8\migracion.php on line 12

This is the code I am using.

define('DRUPAL_DIR', __DIR__);
use \Drupal\Core\DrupalKernel;
use \Symfony\Component\HttpFoundation\Request;
use \Drupal\node\Entity\Node;
use \Drupal\file\Entity\File;
use \Drupal\pathauto\PathautoState;

$fileContentXML = file_get_contents(DRUPAL_DIR . "/sites/default/files/migration/data.xml");
$xml_file = simplexml_load_string($fileContentXML);
foreach ($xml_file->channel->item as $item) {
  $node = Node::create(['type' => 'article']);
  $nid = trim($item->nid);
  $node->set('nid', $nid);
  $node->set('uid', 1);
  $node->enforceIsNew();
  $node->save();
}

How can I fix this error?

added 21 characters in body
Source Link

I've installed Drupal 8, I've created a PHP file to read a XML file and insert some items, but I'm getting this error.

Fatal error: Uncaught Error: Class 'Drupal\node\Entity\Node' not found in C:\xampp\htdocs\drupal8\migracion.php:12 Stack trace: #0 {main} thrown in C:\xampp\htdocs\drupal8\migracion.php on line 12

This is the code I am using.

define('DRUPAL_DIR', __DIR__);
use \Drupal\Core\DrupalKernel;
use \Symfony\Component\HttpFoundation\Request;
use \Drupal\node\Entity\Node;
use \Drupal\file\Entity\File;
use \Drupal\pathauto\PathautoState;

$fileContentXML = file_get_contents(DRUPAL_DIR . "/sites/default/files/migration/data.xml");
$xml_file = simplexml_load_string($fileContentXML);
foreach ($xml_file->channel->item as $item) {
  $node = Node::create(['type' => 'article']);
  $nid = trim($item->nid);
  $node->set('nid', $nid);
  $node->set('uid', 1);
  $node->enforceIsNew();
  $node->save();
}

How do IThis is line 12 $node = Node::create(['type' => 'article']);

Do you have some idea how can i fix this error?

I've installed Drupal 8, I've created a PHP file to read a XML file and insert some items, but I'm getting this error.

Fatal error: Uncaught Error: Class 'Drupal\node\Entity\Node' not found in C:\xampp\htdocs\drupal8\migracion.php:12 Stack trace: #0 {main} thrown in C:\xampp\htdocs\drupal8\migracion.php on line 12

This is the code I am using.

define('DRUPAL_DIR', __DIR__);
use \Drupal\Core\DrupalKernel;
use \Symfony\Component\HttpFoundation\Request;
use \Drupal\node\Entity\Node;
use \Drupal\file\Entity\File;
use \Drupal\pathauto\PathautoState;

$fileContentXML = file_get_contents(DRUPAL_DIR . "/sites/default/files/migration/data.xml");
$xml_file = simplexml_load_string($fileContentXML);
foreach ($xml_file->channel->item as $item) {
  $node = Node::create(['type' => 'article']);
  $nid = trim($item->nid);
  $node->set('nid', $nid);
  $node->set('uid', 1);
  $node->enforceIsNew();
  $node->save();
}

How do I fix this error?

I've installed Drupal 8, I've created a PHP file to read a XML file and insert some items, but I'm getting this error.

Fatal error: Uncaught Error: Class 'Drupal\node\Entity\Node' not found in C:\xampp\htdocs\drupal8\migracion.php:12 Stack trace: #0 {main} thrown in C:\xampp\htdocs\drupal8\migracion.php on line 12

This is the code I am using.

define('DRUPAL_DIR', __DIR__);
use \Drupal\Core\DrupalKernel;
use \Symfony\Component\HttpFoundation\Request;
use \Drupal\node\Entity\Node;
use \Drupal\file\Entity\File;
use \Drupal\pathauto\PathautoState;

$fileContentXML = file_get_contents(DRUPAL_DIR . "/sites/default/files/migration/data.xml");
$xml_file = simplexml_load_string($fileContentXML);
foreach ($xml_file->channel->item as $item) {
  $node = Node::create(['type' => 'article']);
  $nid = trim($item->nid);
  $node->set('nid', $nid);
  $node->set('uid', 1);
  $node->enforceIsNew();
  $node->save();
}

This is line 12 $node = Node::create(['type' => 'article']);

Do you have some idea how can i fix this error?

added 3 characters in body
Source Link
Loading
edited title
Source Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284
Loading
Source Link
Loading