The Clean Architecture in php


Integrating Zend Framework and Doctrine



Download 2,26 Mb.
Pdf ko'rish
bet166/179
Sana24.06.2021
Hajmi2,26 Mb.
#100337
1   ...   162   163   164   165   166   167   168   169   ...   179
Bog'liq
The-Clean-Architecture-in-PHP-Kristopher-Wilson

Integrating Zend Framework and Doctrine
The next step is to wire up Zend Framework and Doctrine to work together. This turns out to be
pretty simple thanks to
DoctrineOrmModule⁶¹
, a ZF2 module written by the Doctrine team to
integrate the two projects.
We’ll grab the latest version with Composer:
⁶¹
https://github.com/doctrine/DoctrineORMModule


Doctrine 2
204
composer require doctrine/doctrine-orm-module
DoctrineOrmModule will bring all the necessary Doctrine dependencies along with it. Now we
just have to configure this module within Zend Framework and we’re ready to use it.
The first thing we’ll want to do is enable the DoctrineORMModule and DoctrineModule (a
dependency of DoctrineORMModule):
// config/application.config.php
return
[
'modules'
=>
[
'DoctrineModule'
,
'DoctrineORMModule'
,
'Application'
,
],
// ...
];
Next, we’ll drop in a global configuration file to define the basics of the Doctrine setup, including
which mapping driver to use, where to find the entities, and where to find the mapping files:
// config/autoload/db.global.php
return
[
'doctrine'
=>
[
'driver'
=>
[
'orm_driver'
=>
[
'class'
=>
'Doctrine\ORM\Mapping\Driver\YamlDriver'
,
'cache'
=>
'array'
,
'paths'
=>
[
realpath
(__DIR__
.
'/../../src/Domain/Entity'
),
realpath
(__DIR__
.
'/../../src/Persistence/Doctrine/Mapping'
)
],
],
'orm_default'
=>
[
'drivers'
=>
[
'CleanPhp\Invoicer\Domain\Entity'
=>
'orm_driver'
]
]
],
],
];
We’ll also modify
db.local.php
file to setup the database connection information for Doc-
trineModule. This is the same information we had previously, just modified slightly to fit the
format expected by DoctrineModule:


Doctrine 2
205
// config/autoload/db.local.php
return
[
'doctrine'
=>
[
'connection'
=>
[
'orm_default'
=>
[
'driverClass'
=>
'Doctrine\DBAL\Driver\PDOSqlite\Driver'
,
'params'
=>
[
'path'
=>
__DIR__
.
'/../../data/database.db'
,
]
]
],
],
];
And that’s it! Zend Framework is now configured to use Doctrine, so let’s start using it.

Download 2,26 Mb.

Do'stlaringiz bilan baham:
1   ...   162   163   164   165   166   167   168   169   ...   179




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish