Doctrine 2 ORM integration for Hawkbit PSR-7 Micro PHP framework

dev-master 2016-12-15 09:10 UTC

This package is not auto-updated.

Last update: 2023-02-04 10:36:56 UTC


Latest Version on Packagist Software License Build Status Total Downloads Coverage Status

Doctrine 2 ORM integration for Hawkbit PSR-7 Micro PHP framework.


Using Composer

Hawkbit Doctrine is available on Packagist and can be installed using Composer. This can be done by running the following command or by updating your composer.json file.

composer require hawkbit/doctrine


    "require": {
        "hawkbit/doctrine": "~1.0"

Be sure to also include your Composer autoload file in your project:


require __DIR__ . '/vendor/autoload.php';

Downloading .zip file

This project is also available for download as a .zip file on GitHub. Visit the releases page, select the version you want, and click the "Source code (zip)" download button.


The following versions of PHP are supported by this version.

  • PHP 5.5
  • PHP 5.6
  • PHP 7.0
  • PHP 7.1
  • HHVM


Setup with an existing application configuration (we refer to tests/assets/config.php)


use \Hawkbit\Application;
use \Hawkbit\Doctrine\DoctrineService;
use \Hawkbit\Doctrine\DoctrineServiceProvider;

$app = new Application(require_once __DIR__ . '/config.php');

$entityFactoryClass = \ContainerInteropDoctrine\EntityManagerFactory::class;

$doctrineService = new DoctrineService([
   DoctrineService::resolveFactoryAlias($entityFactoryClass) => [$entityFactoryClass]
], $app);

$app->register(new DoctrineServiceProvider($doctrineService));


Full configuration

A full configuration is available on DASPRiD/container-interop-doctrine/example/full-config.php. Refer to container-interop-doctrine Documentation for further instructions on factories.

Doctrine from Hawbit Application


/** @var \Hawkbit\Doctrine\DoctrineServiceInterface $doctrine */
$doctrine = $app[\Hawkbit\Doctrine\DoctrineServiceInterface::class];

$em = $doctrine->getEntityManager();

// or with from specific connection
$em = $doctrine->getEntityManager('connectionname');

Doctrine in a Hawkbit controller

Access doctrine service in controller. Hawbit is inject classes to controllers by default.


use \Hawkbit\Doctrine\DoctrineServiceInterface;

class MyController{
     * @var \Hawkbit\Doctrine\DoctrineServiceInterface 
    private $doctrine = null;
    public function __construct(DoctrineServiceInterface $doctrine){
        $this->doctrine = $doctrine;
    public function index(){
        $em = $this->doctrine->getEntityManager();
        // or with from specific connection
        $em = $this->doctrine->getEntityManager('connectionname');

Change log

Please see CHANGELOG for more information what has changed recently.


$ composer test


Please see CONTRIBUTING for details.


If you discover any security related issues, please email mjls@web.de instead of using the issue tracker.



The MIT License (MIT). Please see License File for more information.