2017 © Pedro Peláez
 

library lynx

Awesome Mapper on top of DBAL/Doctrine2

image

lynx/lynx

Awesome Mapper on top of DBAL/Doctrine2

  • Wednesday, April 13, 2016
  • by ovr
  • Repository
  • 2 Watchers
  • 5 Stars
  • 119 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Lynx

Build Status Scrutinizer Code Quality Code Coverage, (*1)

An awesome Mapper on top of Doctrine 2 components, (*2)

How to work?

First you need to setup EntityManager ($em) :, (*3)

$configuration = new Configuration();
$configuration->setResultCacheImpl($di->getCache());
$configuration->setMetadataDriverImpl(
    new \Doctrine\ORM\Mapping\Driver\AnnotationDriver(
        new AnnotationReader(),
        realpath(APP_ROOT_PATH . '/src/BlaBla/User/Model/')
    )
);
$configuration->setMetadataCacheImpl(
    new \Doctrine\Common\Cache\ApcCache()
);

$em = new \Lynx\EntityManager(
    $di->getDb(),
    $configuration
);

Working with repository

You can get a Repository for Model by using method getRepository from EntityManager:, (*4)

$repository = $em->getRepository(User::class);

For example, you can get one row by using:, (*5)

$repository = $em->getRepository(User::class);
/** User|null $user */
$user = $repository->findOne(1);

You can count all rows from table:, (*6)

$repository = $em->getRepository(User::class);
$count = $repository->count();

Testing

PostgresSQL

sudo docker run --name lynx-test -p 5432:5432 -e POSTGRES_PASSWORD= -d postgres
psql -p 5432 -h 127.0.0.1 -U postgres -c 'create database lynx_test;'
psql -p 5432 -h 127.0.0.1 -U postgres -d lynx_test -f tests/schemas/pqsql/lynx_test.sql

LICENSE

MIT, (*7)

The Versions