2017 © Pedro Peláez
 

library doctrine

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

image

hawkbit/doctrine

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

  • Thursday, December 15, 2016
  • by mbunge
  • Repository
  • 1 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Hawkbit Doctrine

Latest Version on Packagist ![Software License][ico-license] Build Status ![Total Downloads][ico-downloads] Coverage Status, (*1)

Doctrine 2 ORM integration for Hawkbit PSR-7 Micro PHP framework., (*2)

Install

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., (*3)

composer require hawkbit/doctrine

composer.json, (*4)

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

Be sure to also include your Composer autoload file in your project:, (*5)

<?php

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., (*6)

Requirements

The following versions of PHP are supported by this version., (*7)

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

Setup

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

<?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));

Examples

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., (*9)

Doctrine from Hawbit Application

<?php

/** @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., (*10)

<?php

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., (*11)

Testing

bash $ composer test, (*12)

Contributing

Please see CONTRIBUTING for details., (*13)

Security

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

Credits

License

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

The Versions

15/12 2016

dev-master

9999999-dev https://github.com/HawkBitPhP

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

  Sources   Download

MIT

The Requires

 

The Development Requires

orm doctrine persistence hawkbit