Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Doctrine automatically create all the database tables?

Tags:

doctrine-orm

is there any way to tell doctrine automaticaly create schema tables without using this command :

doctrine:schema:update --force
like image 243
Sina Miandashti Avatar asked May 20 '12 15:05

Sina Miandashti


People also ask

What is Doctrine database?

The Doctrine Project is the home to several PHP libraries primarily focused on database storage and object mapping. The core projects are the Object Relational Mapper (ORM) and the Database Abstraction Layer (DBAL) it is built upon. Get Started View Projects.

How does Doctrine work?

Doctrine uses the Identity Map pattern to track objects. Whenever you fetch an object from the database, Doctrine will keep a reference to this object inside its UnitOfWork. The array holding all the entity references is two-levels deep and has the keys root entity name and id.

What is doctrine repository?

A repository in a term used by many ORMs (Object Relational Mappers), doctrine is just one of these. It means the place where our data can be accessed from, a repository of data. This is to distinguish it from a database as a repository does not care how its data is stored.

What is doctrine Symfony?

Symfony provides all the tools you need to use databases in your applications thanks to Doctrine, the best set of PHP libraries to work with databases. These tools support relational databases like MySQL and PostgreSQL and also NoSQL databases like MongoDB.


1 Answers

Using SchemaTool and EntityManager you can do this:

$schemaTool = new \Doctrine\ORM\Tools\SchemaTool($entityManager);
$classes = $entityManager->getMetadataFactory()->getAllMetadata();
$schemaTool->createSchema($classes);
like image 93
trevorengstrom Avatar answered Sep 21 '22 18:09

trevorengstrom