原则类加载器.php“;无法打开流:没有这样的文件或目录";

原则类加载器.php“;无法打开流:没有这样的文件或目录";,php,doctrine,Php,Doctrine,我得到这个错误: 警告:require(1):无法打开流:第8行的/var/www/tests/index.php中没有此类文件或目录 致命错误:require():无法在/var/www/tests/index.php第8行打开所需的“1”(include_path=。:/usr/share/php:/usr/local/lib/smarty-3.1.13/libs) 有人能帮我弄明白这里出了什么问题吗?有些奇怪 ... 必需的“1” 无论如何,检查1)和2)或需要的更多信息 1) 在第8行之

我得到这个错误:

警告:require(1):无法打开流:第8行的/var/www/tests/index.php中没有此类文件或目录

致命错误:require():无法在/var/www/tests/index.php第8行打开所需的“1”(include_path=。:/usr/share/php:/usr/local/lib/smarty-3.1.13/libs)

有人能帮我弄明白这里出了什么问题吗?

有些奇怪 ... 必需的“1”

无论如何,检查1)和2)或需要的更多信息

1) 在第8行之前,显示包含文件的列表。检查是否已加载ClassLoader.php


2) 新的类加载器(“条令”)将在PHP include_路径中找到条令*名称空间。这包括。(当前路径)在您的情况下,检查此目录中的条令库(子目录也可以)。

经常遇到此错误,要快速排除故障,请执行以下步骤:
<?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();
    
?>