2017 © Pedro Peláez
 

library laravel-doctrine

Doctrine 2 for Laravel 5 Artisans

image

paolooo/laravel-doctrine

Doctrine 2 for Laravel 5 Artisans

  • Thursday, April 30, 2015
  • by paolooo
  • Repository
  • 2 Watchers
  • 3 Stars
  • 56 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Doctrine 2 Service for Laravel 5+

Latest Stable Version Total Downloads Latest Unstable Version License Build Status, (*1)

Run all doctrine commands easily using $ php artisan doctrine <command> <options>, (*2)

This service will grab your laravel's configuration (db and cache) and automatically apply it to doctrine2 configurate, no more hassle configuration needed. :), (*3)

  • Supports all Doctrine's command line.
  • Supports multiple DB connection.

Installation

$ composer require "paolooo/laravel-doctrine":"0.4.*@dev"

Open and edit config/app.php configuration file, and add the following service provider code to the $providers array., (*4)

        'Paolooo\LaravelDoctrine\LaravelDoctrineServiceProvider',

Edit .env file. Add the following doctrine config. For more information, of doctrine configuration, see, http://doctrine-orm.readthedocs.org/en/latest/reference/advanced-configuration.html., (*5)

# .env
...

DOCTRINE_PROXY_AUTOGENERATED=false
DOCTRINE_PROXY_NAMESPACE=Acme\Domain\Model\Proxy
DOCTRINE_PROXY_DIR=app/Domain/Model/Proxy
DOCTRINE_MAPPING_DIR=app/Domain/Model

# READ
READ_DB_DATABASE=cqrs_read_db
READ_DOCTRINE_PROXY_AUTOGENERATED=false
READ_DOCTRINE_PROXY_NAMESPACE=app\Query\Model\Proxy
READ_DOCTRINE_PROXY_DIR=app/Query/Model/Proxy
READ_DOCTRINE_MAPPING_DIR=app/Query/Model

This configuration is for testing environment. Edit phpunit.xml file., (*6)

# phpunit.xml


<phpunit ...>
    ....
    <php>
        ...
        <env name="DB_DRIVER" value="pdo_sqlite"/>
        <env name="DB_DATABASE" value="storage/tests/db.sqlite"/>
        <env name="READ_DB_DATABASE" value="storage/tests/db_read.sqlite"/>
    </php>
</phpunit>

Usage

<?php

# Create new EntityManager
$em = \App::make('Doctrine\ORM\EntityManager');

# Saving user entity to a 'default' database connection
# you can use `$em->on('default')` as well.
$em->getRepository('Paolooo\Acme\Domain\Entity\User')->persist($user);
$em->flush();

# Saving user entity to a 'read' database
$em->on('read')
    ->getRepository('Paolooo\Acme\Domain\Entity\User')
    ->persist($user);
$em->on('read')->flush();

Multiple Connection

$em = \App::make('Doctrine\ORM\EntityManager');
...
$em->on('read')->persist($user);
$em->on('read')->flush();

$em->on('eventStore')->persist($user);
$em->on('eventStore')->flush();

Running Doctrine Commands

Sample artisan for doctrine., (*7)

$ php artisan doctrine
$ php artisan doctrine help orm:schema-tool:create
$ php artisan doctrine orm:schema-tool:create
$ php artisan doctrine orm:schema-tool:create --dump-sql
$ php artisan doctrine orm:schema-tool:update
$ php artisan doctrine orm:schema-tool:drop

Example

See examples/ directory., (*8)

  • Sample config file, see .env and phpunit.xml files.
  • Sample User entity class, see Acme/Domain/Model/Entity/User.php file.
  • Sample ModelTestCase. This will get the setup doctrine for you. Sets $this->entityManager. Create and drop schema as well.

Learn doctrine here http://doctrine-orm.readthedocs.org/en/latest/tutorials/getting-started.html, (*9)

TODO

  • Migration

The Versions

30/04 2015

dev-master

9999999-dev

Doctrine 2 for Laravel 5 Artisans

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nino Paolo Amarillento

orm laravel doctrine

08/04 2015

0.4.0

0.4.0.0

Doctrine 2 for Laravel 5 Artisans

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nino Paolo Amarillento

orm laravel doctrine

13/02 2015

0.1.1

0.1.1.0

Doctrine 2 for Laravel 5 Artisans

  Sources   Download

MIT

The Requires

 

by Nino Paolo Amarillento

orm laravel doctrine

13/02 2015

0.1.0

0.1.0.0

Doctrine 2 for Laravel 5 Artisans

  Sources   Download

MIT

The Requires

 

by Nino Paolo Amarillento

orm laravel doctrine