PHPackages                             yong/magento2\_doctrine - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. yong/magento2\_doctrine

ActiveMagento2-module

yong/magento2\_doctrine
=======================

Magento 2 Doctrine extension

11PHP

Since Jan 11Pushed 8y ago1 watchersCompare

[ Source](https://github.com/yongchengchen/magento2_doctrine)[ Packagist](https://packagist.org/packages/yong/magento2_doctrine)[ RSS](/packages/yong-magento2-doctrine/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)DependenciesVersions (1)Used By (0)

### Doctrine ORM support for Magneto2

[](#doctrine-orm-support-for-magneto2)

[![Total Downloads](https://camo.githubusercontent.com/fe1f4ce85c49dae545ba9c4ba20636508f503b806dc9e0eca29ac6b61ed7c3b6/68747470733a2f2f706f7365722e707567782e6f72672f796f6e672f6d6167656e746f325f646f637472696e652f642f746f74616c2e737667)](https://packagist.org/packages/yong/magento2_doctrine)[![Latest Stable Version](https://camo.githubusercontent.com/bde740d710c33055274e7283dacf62e8800ed8d7112d35d3b9abb9e475dcb417/68747470733a2f2f706f7365722e707567782e6f72672f796f6e672f6d6167656e746f325f646f637472696e652f762f737461626c652e737667)](https://packagist.org/packages/yong/magento2_doctrine)[![Latest Unstable Version](https://camo.githubusercontent.com/56b04af4dd5952fa73ee3f9e6757b8108b9e6c0380804f10fd472f4540939d19/68747470733a2f2f706f7365722e707567782e6f72672f796f6e672f6d6167656e746f325f646f637472696e652f762f756e737461626c652e737667)](https://packagist.org/packages/yong/magento2_doctrine)[![License](https://camo.githubusercontent.com/1f41978092107f5cd4bee74b6914bd5a0697758beadc977f3e260a5ffde7bf05/68747470733a2f2f706f7365722e707567782e6f72672f796f6e672f6d6167656e746f325f646f637472696e652f6c6963656e73652e737667)](https://packagist.org/packages/yong/elasticsuit)Github: ([https://packagist.org/packages/yong/magento2\_doctrine](https://packagist.org/packages/yong/magento2_doctrine))

Our system has some tables for exist system which developed by Laravel,

And we using Magento2 CE which not support multiple databases.

On the other side, Magento 2 encapsulates database model a little bit too complicated.

So we need a rapid solution to retrieve these data model from 3rd database, and we decided to use Doctrine ORM.

#### \* It's packaged as Magento 2 Module, but you don't have to enable this module to use it.

[](#-its-packaged-as-magento-2-module-but-you-dont-have-to-enable-this-module-to-use-it)

### Installation

[](#installation)

#### 1.Via Composer

[](#1via-composer)

run command:

```
composer require yong/magento2_doctrine dev
```

#### 2. Download by git

[](#2-download-by-git)

Download this repo to the path app/code/Yong/Doctrine

```
    cd root_path_of_magento2
    git clone https://github.com/yongchengchen/magento2_doctrine.git app/code/Yong/Doctrine
```

### Usage

[](#usage)

#### 1. Config Database Connection

[](#1-config-database-connection)

Edit root\_path\_of\_magento2/app/etc/env.php

Add your database connection configuration to 'db.connection' node

```
      'my_connection' =>
        array (
            'host' => 'mysql',
            'dbname' => 'mydb',
            'username' => 'root',
            'password' => 'root',
            'active' => '1',
        ),
```

#### 2. Define Model

[](#2-define-model)

Define a model for your table.

```
