• This repository has been archived on 28/Mar/2022
  • Stars
    star
    107
  • Rank 322,623 (Top 7 %)
  • Language
    PHP
  • Created over 8 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Doctrine factories for container-interop

container-interop-doctrine: Doctrine Factories for PSR-11

THIS REPOSITORY IS DEPRECATED - PLEASE VISIT https://github.com/Roave/psr-container-doctrine

Latest Stable Version Total Downloads Build Status Coverage Status

Doctrine factories for PSR-11 (previously known as container-interop).

This package provides a set of factories to be used with containers using the PSR-11 standard for an easy Doctrine integration in a project.

Installation

The easiest way to install this package is through composer:

$ composer require dasprid/container-interop-doctrine

Configuration

In the general case where you are only using a single connection, it's enough to define the entity manager factory:

return [
    'dependencies' => [
        'factories' => [
            'doctrine.entity_manager.orm_default' => \ContainerInteropDoctrine\EntityManagerFactory::class,
        ],
    ],
];

If you want to add a second connection, or use another name than "orm_default", you can do so by using the static variants of the factories:

return [
    'dependencies' => [
        'factories' => [
            'doctrine.entity_manager.orm_other' => [\ContainerInteropDoctrine\EntityManagerFactory::class, 'orm_other'],
        ],
    ],
];

Each factory supplied by this package will by default look for a registered factory in the container. If it cannot find one, it will automatically pull its dependencies from on-the-fly created factories. This saves you the hassle of registering factories in your container which you may not need at all. Of course, you can always register those factories when required. The following additional factories are available:

  • \ContainerInteropDoctrine\CacheFactory (doctrine.cache.*)
  • \ContainerInteropDoctrine\ConnectionFactory (doctrine.connection.*)
  • \ContainerInteropDoctrine\ConfigurationFactory (doctrine.configuration.*)
  • \ContainerInteropDoctrine\DriverFactory (doctrine.driver.*)
  • \ContainerInteropDoctrine\EventManagerFactory (doctrine.event_manager.*)

Each of those factories supports the same static behavior as the entity manager factory. For container specific configurations, there are a few examples provided in the example directory:

Example configuration

A complete example configuration can be found in example/full-config.php. Please note that the values in there are the defaults, and don't have to be supplied when you are not changing them. Keep your own configuration as minimal as possible. A minimal configuration can be found in example/minimal-config.php

Using the Doctrine CLI

In order to be able to use the CLI tool of Doctrine, you need to set-up a cli-config.php file in your project directory. That file is generally quite short, and should look something like this for you:

<?php
$container = require 'config/container.php';

return new \Symfony\Component\Console\Helper\HelperSet([
    'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper(
        $container->get('doctrine.entity_manager.orm_default')
    ),
]);

After that, you can simply invoke php vendor/bin/doctrine. It gets a little trickier when you have multiple entity managers. Doctrine itself has no way to handle that itself, so a possible way would be to have two separate directories with two unique cli-config.php files. You then invoke the doctrine CLI from each respective directory. Since the CLI is looking for the config file in the current working directory, it will then always use the one from the directory you are currently in.

More Repositories

1

Enum

PHP 7.1 enum implementation
PHP
335
star
2

Flitch

PHP Coding Standard Validator
PHP
58
star
3

ZFCS

Zend Framework 2 Coding Standard
PHP
31
star
4

Helios

PSR-7 authentication middleware
PHP
30
star
5

vnstat-php

PHP frontend for vnStat
PHP
29
star
6

Dash

Flexible PSR-7 compliant HTTP router
PHP
29
star
7

Formidable

PHP 7 form library for handling user input
PHP
27
star
8

Ajasta

Ajasta is a simple invoicing application built with the latest technologies on the market.
PHP
26
star
9

Torrent-to-Web

Allows to send torrent files to web clients.
TypeScript
22
star
10

gimp-telegram-sticker

Makes a telegram sticker out of the current image
Python
21
star
11

Bacon

ZF2 module for common code across projects
PHP
21
star
12

gnome-shell-extension-area-screenshot

Extension to make screenshots of a selected area.
JavaScript
17
star
13

AssetLoader

AssetLoader module for ZF2
PHP
13
star
14

localized-address-format

Zero-dependency address formatting library.
TypeScript
13
star
15

DASBiT

Python based IRC bot
Python
9
star
16

Bootstrap-DatePicker

A simple datepicker for Bootstrap 3
8
star
17

gnome-screenshot-uploader

Upload wrapper for GNOME Screenshot
Python
5
star
18

DASBiT-PHP

PHP-based IRC bot
PHP
5
star
19

timetrap-to-jira

A simple utility to transfer your hours from timetrap to JIRA
PHP
5
star
20

jsonapi-zod-query

JSON:API Query Helpers utilizing Zod
TypeScript
5
star
21

Cbor

A PHP implementation of Concise Binary Object Representation (CBOR)
PHP
4
star
22

mui-rhf-integration

React Hook Form integration for MUI with strict TypeScript handling based on form context.
TypeScript
4
star
23

react-confirm-hook

Programmatically ask for user confirmation with custom confirm dialogs.
TypeScript
4
star
24

TreeReader

Structured array tree reader
PHP
3
star
25

RouterBenchmark

PHP
3
star
26

vrc-osc-manager

OSC client for managing VRChat accessories
Rust
3
star
27

google-form-telegram-bot-notifications

HTML
3
star
28

karlsfurs-registration

Registration system for the karlsfurs suitwalk
PHP
3
star
29

zod-joda

JS-Joda integration for Zod validation library
TypeScript
2
star
30

jsTyrian

JavaScript port of OpenTyrian
JavaScript
2
star
31

bitbucket-code-pipeline-integration

A simple Serverless project to assist in integrating on-premise Bitbucket with AWS CodePipeline.
TypeScript
2
star
32

eslint-config-dasprid

Strict ESLint configuration for TypeScript projects
JavaScript
2
star
33

SplBitArray

C++
2
star
34

shoutirc-php-client

Client for the ShoutIRC socket server
PHP
2
star
35

Pikkuleipa

PSR-7 JWT cookie handler
PHP
1
star
36

MyBackupr

CLI backup tool for Flickr
Python
1
star
37

CSRF-Guard

CSRF guard for middleware based applications
PHP
1
star
38

phpapidoc

PSR-5 compliant API doc generator
PHP
1
star
39

dasprids.de

My personal website and blog
PHP
1
star
40

dash-expressive

Bridge between Dash and Zend-Expressive
PHP
1
star
41

osc-watch-linux

OSC Linux client for the OSC Watch VRChat accessory
Rust
1
star
42

timetrap-to-harvest

A simple utility to transfer your hours from timetrap to Harvest
PHP
1
star
43

aw2013

Rust Driver for the AW2013 3-Channel LED Controller.
Rust
1
star