0
<?php
    
    use vendor\doctrine\common\lib\Doctrine\Common\ClassLoader,
    vendor\doctrine\orm\lib\Doctrine\ORM\EntityManager;

    require 'vendor/doctrine/common/lib/Doctrine/Common/ClassLoader.php' or die();

    $loader = new ClassLoader("Doctrine");
    $loader->register();

    $dbParams = array(
        'driver' => 'pdo_mysql',
        'user' => 'root',
        'password' => 'password',
        'dbname' => 'test_doctrine'
    );
    $path = 'entities/';
    $config = Setup::createAnnotationMetadataConfiguration($path, true);
    $entityManager = EntityManager::create($dbParams, $config);

    $user=new User();
    $post=new Post($user);

    $post->addComment("First comment");
    $post->addComment("Seconde comment");

    $entityManager->persist($user);
    $entityManager->persist($post);
    $entityManager->flush();
    
?>

i get this error:

Warning: require(1): failed to open stream: No such file or directory in /var/www/tests/index.php on line 8

Fatal error: require(): Failed opening required '1' (include_path='.:/usr/share/php:/usr/local/lib/smarty-3.1.13/libs') in /var/www/tests/index.php on line 8

Can somebody help me understand whats wrong here?

Community
  • 1
  • 1
Younes Rafie
  • 21
  • 2
  • 4

1 Answers1

0

some weird that ... required '1' ...

anyway check 1) and 2) or further information needed.

1) Before line 8, get_included_files shows a list of included files. check ClassLoader.php was loaded.

2) new ClassLoader("Doctrine") will find Doctrine* namespaces in your PHP include_path. This includes .(current path) in your case, check your Doctrine library in this(subdirectory is also okay).

jnhwkim
  • 128
  • 6