hawkbit / doctrine
Doctrine 2 ORM integration for Hawkbit PSR-7 Micro PHP framework
Requires
- php: >=5.6
- dasprid/container-interop-doctrine: ^0.2
- doctrine/orm: ~2.5
- hawkbit/hawkbit: ~2.0
Requires (Dev)
- phpunit/phpunit: ~4.8
This package is not auto-updated.
Last update: 2024-10-26 20:43:07 UTC
README
Doctrine 2 ORM integration for Hawkbit PSR-7 Micro PHP framework.
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.
composer require hawkbit/doctrine
composer.json
{ "require": { "hawkbit/doctrine": "~1.0" } }
Be sure to also include your Composer autoload file in your project:
<?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.
Requirements
The following versions of PHP are supported by this version.
- 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)
<?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.
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.
<?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.
Testing
$ composer test
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email mjls@web.de instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.