vendor\bin\doctrine orm:schema-tool:update --dump-sql --force
vendor\bin\doctrine orm:validate-schema
composer require doctrine/orm:^2.8.*
Create a file bootstrap.php
PHP |
---|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37 | <?php
# bootstrap.php
require_once join(DIRECTORY_SEPARATOR, [__DIR__, 'vendor', 'autoload.php']);
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;
$entitiesPath = [
join(DIRECTORY_SEPARATOR, [__DIR__, "src", "Entity"])
];
$isDevMode = true;
$proxyDir = null;
$cache = null;
$useSimpleAnnotationReader = false;
// Connexion à la base de données
$dbParams = [
'driver' => 'pdo_mysql',
'host' => 'localhost',
'charset' => 'utf8',
'user' => 'root',
'password' => '123456',
'dbname' => 'todo',
];
$config = Setup::createAnnotationMetadataConfiguration(
$entitiesPath,
$isDevMode,
$proxyDir,
$cache,
$useSimpleAnnotationReader
);
$entityManager = EntityManager::create($dbParams, $config);
return $entityManager;
|
Create file cli-config.php
PHP |
---|
| <?php
# cli-config.php
$entityManager = require_once join(DIRECTORY_SEPARATOR, [__DIR__, 'bootstrap.php']);
use Doctrine\ORM\Tools\Console\ConsoleRunner;
return ConsoleRunner::createHelperSet($entityManager);
|
Create a Database called like in the bootstrap.php file