未找到“Doc​​trine\Common\Annotations\AnnotationRegistry”类

Jos*_*low 9 php doctrine doctrine-orm

My first ever time using Doctrine and I've got an error. I left my project the night before and this error didn't exist, booted up the web server on a new machine and greeted with this.

Fatal error: Uncaught Error: Class 'Doctrine\Common\Annotations\AnnotationRegistry' not found in D:\website\vendor\doctrine\orm\lib\Doctrine\ORM\Configuration.php:156 Stack trace: #0 D:\website\vendor\doctrine\orm\lib\Doctrine\ORM\Tools\Setup.php(72): Doctrine\ORM\Configuration->newDefaultAnnotationDriver(Array, true) #1 D:\website\src\setup.php(16): Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration(Array, true) #2 D:\website\src\bootstrap.php(6): include('C:\Users\admin\...') #3 D:\website\public\index.php(7): require('C:\Users\admin\...') #4 {main} thrown in D:\website\vendor\doctrine\orm\lib\Doctrine\ORM\Configuration.php on line 156

I've tried composer update and composer install, neither have helped.

use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;

$paths = array(ROOT . "/src/Database/Modals");
$config = $container->get('App\Providers\Config');

$dbParams = array(
    'driver'   => $config->get('database.driver'),
    'user'     => $config->get('database.user'),
    'password' => $config->get('database.password'),
    'dbname'   => $config->get('database.name'),
);

$entityConfig = Setup::createAnnotationMetadataConfiguration($paths, true);
$entityManager = EntityManager::create($dbParams, $entityConfig);
Run Code Online (Sandbox Code Playgroud)

It seems to throw the exception for this line of code.

$entityConfig = Setup::createAnnotationMetadataConfiguration($paths, true);
Run Code Online (Sandbox Code Playgroud)

Ker*_*lph 11

@martin-barker 的上述评论对我有用:

composer require doctrine/annotations
Run Code Online (Sandbox Code Playgroud)


小智 1

1)使用 ssh 连接您的服务器。

2) 找到脚本运行的路径。

3)运行composer require doctrine/annotations

4) 您可以在 FTP 中找到供应商目录

5) 向供应商声明您的代码的要求。喜欢require_once 'vendor/autoload.php'

如果有帮助请告诉我。