Good Morning,
Firstly, I want to inform you that English is not my first language, and I apologize for my imperfect English. I’m also new to use networks
.
I installed Slim and I test it with a crud with success
I want now to install with slim the Doctrine ORM, like this:
slimframework
In the bootstrap.php, there are underlines ("Undefined type").
here the accessible code:
<?php
namespace Appconfig;
// bootstrap.php
use DoctrineCommonCachePsr6DoctrineProvider;
use DoctrineORMEntityManager;
use DoctrineORMToolsSetup;
use SymfonyComponentCacheAdapterArrayAdapter;
use SymfonyComponentCacheAdapterFilesystemAdapter;
use UMADICContainer;
$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);
-
The classes importations seem good (no underline). But most of the folders and classes of the code doesn’t exist in the folder "vendor")
-
I have tried to delete the folder vendor and the composer.lock folder:
rm -rf vendor/ composer.lock
then
require composer
-
I have reinstalled with no success.
-
The problem is the same with phpStorm.
Thank’s for your help.
2
Answers
I think after reading and progamming,, I think I understand some things. I'm a beginner in framework, so, please be indulgent. I hope I don't say stupid things.
Last program:
The new program (Slim - PHP-DI - Doctine) - it's 's work. I have used:
Secutiy and gestion management and error management are not implemented at the moment Here are the programs:
src/Models/student.php (personnal code):
Since there are lot of classes that are not available (and the slim documentation is not updated according to the last version of packages), you will have to adapt the code yourself. For example, DoctrineProvider class was abandoned after "doctrine/orm": "^2.19". So you will have to change your bootstrap file like this:
Enough talking, i created a basic example
php slim basic from Github Codespaces with php 8.2