早上好,
首先,我想告诉你,英语不是我的母语,对于我不完美的英语,我深表歉意。我也是网络新手 。 我安装了 Slim 并用 crud 测试它成功了
我现在想用 slim 安装 Doctrine ORM,如下所示: 纤薄框架
在 bootstrap.php 中,有下划线(“未定义类型”)。
这里是可访问的代码:
<?php
namespace App\config;
// bootstrap.php
use Doctrine\Common\Cache\Psr6\DoctrineProvider;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Tools\Setup;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
use UMA\DIC\Container;
$container = new Container(require __DIR__ . '/settings.php');
$container->set(EntityManager::class, static function (Container $c): EntityManager {
/** @var array $settings */
$settings = $c->get('settings');
// Use the ArrayAdapter or the FilesystemAdapter depending on the value of the 'dev_mode' setting
// You can substitute the FilesystemAdapter for any other cache you prefer from the symfony/cache library
$cache = $settings['doctrine']['dev_mode'] ?
DoctrineProvider::wrap(new ArrayAdapter()) :
DoctrineProvider::wrap(new FilesystemAdapter(directory: $settings['doctrine']['cache_dir']));
$config = Setup::createAttributeMetadataConfiguration(
$settings['doctrine']['metadata_dirs'],
$settings['doctrine']['dev_mode'],
null,
$cache
);
return EntityManager::create($settings['doctrine']['connection'], $config);
});
return $container;
($routes = require __DIR__ . '/routes.php')($app);
类的输入看起来不错(没有下划线)。但代码的大部分文件夹和类并不存在于“vendor”文件夹中)
我尝试删除文件夹vendor和composer.lock文件夹:
rm -rf vendor/ composer.lock
然后
require composer
我已重新安装但没有成功。
问题与phpStorm相同。
感谢您的帮助。
您必须安装“doctrine/orm”:“^2.19”和“uma/dic”:“^2”才能解决这些缺失的类问题。我安装了 PHP 7.4,这是安装所有必需的依赖项后 Composer.json 文件的内容。一切正常。
"require": {
"doctrine/orm": "^2.19",
"symfony/cache": "^5.4",
"doctrine/annotations": "^2.0",
"uma/dic": "^2"
}