Database

Tomahawk comes with Doctrine as its database layer. Although there's nothing stopping you adding your own.

The Doctrine service provides a Object Relational Mapper (ORM) and the Database Abstraction Layer (DBAL).

Configuration

Open app/config/doctrine.php in a text editor. Doctrine has more options than Illuminate as it is more configurable.

Here you can set your default connection, all your connections, caching, mapping format and directory.

Below is an example of what your config might look like:

Using Doctrine

Getting an Doctrine Registry

To get the Doctrine Registry where the EntityManager is stored just access your container as below:


Getting the Entity Manager

To retrieve the Entity Manager you would do the following:


Getting an Entity Repository

To retrieve a Repository for an Entity you would do the following:

You can then use it like you normally would. e.g.

Doctrine Mappings


By default Doctrine Migrations are created in Resources/Doctrine/mappings. You Can edit this config if you want them to be created/stored elsewhere by editing the mapping_directories setting in app/config/doctrine.php.

Doctrine Proxies


By default Doctrine Proxies are created in Resources/Doctrine/proxies. You Can edit this config if you want them to be created/stored elsewhere by editing the proxy_directories setting in app/config/doctrine.php.

Doctrine Migrations


By default Doctrine Migrations are created in Resources/Doctrine/migrations. You Can edit this config if you want them to be created/stored elsewhere by editing the migrations_directory setting in app/config/doctrine.php.