The Clean Architecture in php


use CleanPhp\Invoicer\Domain\Entity\Customer; use



Download 2,26 Mb.
Pdf ko'rish
bet151/179
Sana24.06.2021
Hajmi2,26 Mb.
#100337
1   ...   147   148   149   150   151   152   153   154   ...   179
Bog'liq
The-Clean-Architecture-in-PHP-Kristopher-Wilson

use
CleanPhp\Invoicer\Domain\Entity\Customer;
use
CleanPhp\Invoicer\Domain\Entity\Invoice;
use
CleanPhp\Invoicer\Domain\Entity\Order;
use
CleanPhp\Invoicer\Persistence\Zend\DataTable\CustomerTable;
use
CleanPhp\Invoicer\Persistence\Zend\DataTable\InvoiceTable;
use
CleanPhp\Invoicer\Persistence\Zend\DataTable\OrderTable;
use
CleanPhp\Invoicer\Persistence\Zend\TableGateway\TableGatewayFactory;
use
Zend\Stdlib\Hydrator\ClassMethods;


Zend Framework 2 Setup
131
return
[
'service_manager'
=>
[
'factories'
=>
[
// ...
'InvoiceTable'
=>
function
(
$sm
) {
$factory
=
new
TableGatewayFactory();
$hydrator
=
new
ClassMethods();
return new
InvoiceTable(
$factory
->
createGateway
(
$sm
->
get
(
'Zend\Db\Adapter\Adapter'
),
$hydrator
,
new
Invoice(),
'invoices'
),
$hydrator
);
},
'OrderTable'
=>
function
(
$sm
) {
$factory
=
new
TableGatewayFactory();
$hydrator
=
new
ClassMethods();
return new
OrderTable(
$factory
->
createGateway
(
$sm
->
get
(
'Zend\Db\Adapter\Adapter'
),
$hydrator
,
new
Order(),
'orders'
),
$hydrator
);
},
],
],
];
Wrapping it Up
We now have all of our database tables configured and ready to use with Zend Framework 2, as
well as our database configured, ready, and loaded with some dummy Customer data.
Let’s move forward!


Zend Framework 2 Setup
132
This would make a good place to commit your code to source control.
If you’re just reading, but want to see the code in action, you can checkout the tag
04-zf2-database-setup:
git
clone
https
://
github
.
com
/
mrkrstphr
/
cleanphp
-
example
.
git
git checkout
04-
zf2
-
database
-
setup


Our Application in Zend Framework 2
Now that we have Zend Framework configured and ready to rock, as well as our database setup
and configured, we can start actually using it.
Let’s start with customer management. We stubbed out a route, but when we navigate to that
route, we’re going to get a sad error message from ZF2:
A 404 error occurred Page not found. The requested controller could not be mapped
to an existing controller class.
Controller: ApplicationControllerCustomers (resolves to invalid controller class or
alias: ApplicationControllerCustomers) No Exception available
This makes sense as we defined a route to point to a Customers controller, but didn’t bother
creating that controller. So let’s do that.

Download 2,26 Mb.

Do'stlaringiz bilan baham:
1   ...   147   148   149   150   151   152   153   154   ...   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