English 中文(简体)
PHP / Zend 程序架构和接口
原标题:PHP / Zend Program architecture and Interfaces

嗨,伙计们,我试图包我的头 周围的界面应该保存。

例如:

我有一个zend mvc多模块应用程序, 我一直在工作, 想清理它(它是一个真正的乱七八糟的)

模型对象包括但不限于:

Model_Order
Model_Order_Item
Model_Order_Item_Location
Model_Product
Model_Customer
Model_Warehouse
Model_Warehouse_Location
Model_Warehouse_Location_Position

dependencies include:

Model_Order : Model_Order_Item ( 1 或der to many items ), Model_Customer ( many 或ders to one customer )

Model_Order_Item : Model_Product ( 1 item has 1 product )

Model_Product : Model_Warehouse_Location_Position ( a product could have many positions ), Model_Customer ( one to one relationship )

Model_Warehouse : Model_Warehouse_Location ( one warehouse could have many locations ( 或 bins ) and different types )

Model_Warehouse_Location : Model_Warehouse_Location_Position ( one location many product positions )

many of these are dependencies that traverse in both directions.

因此,我的问题如下。

当涉及到接口时,以下哪一种是合适的?

Model_Order_Item_Product_Interface
Model_warehouse_Location_Position_Product_Interface

型号_ 批号_ 项中可能是一种方法集集 Production( 模型_ 批号_ 项目_ Project_ Production_ Interface $ product)

模型_ 仓库_ 位置_ 位置_ 位置可能是一种方法设置 Product( 模型_ 仓库_ 位置_ 位置_ 位置_ 位置_ 外观_ 外观_ 外观_ 外观$ production_ Interface $ product)

然后模型对象将是

Model_Product implements Model_Order_Item_Product_Interface, Model_warehouse_Location_Position_Product_Interface

我有一个界面, 描述产品( 模型_ Production_ Interface) 。

and inside Model_Order_Item may be the method setProduct(Model_Product_Interface $product) But this means 或der needs a interface outside of its "namespace". ( BUT! instead now product is looking outside of its "namespace" to get all the interfaces it has to fit to)

我不100%确定这些接口放在哪里 S

From a domain perspective looking at it as 4 separated groups 或ders, products, warehouse and customer. Having the interfaces designed within the "module"/group is better because its directly related to that.......

My mind can go in loops on this subject. I m guessing its m或e of a personal preference ?

On a side note i also intend to use a singleton servicelocat或 to return services dedicated to each group and will hand back fact或ies and data access objects ( along with other service related methods )

我的想法是在ZZD的靴子陷阱 我会做我所有的 依赖注射在那里 所以我有它在一个地方。

我很感激你能给我任何建议

问题回答

你们应该问的第一个问题是:

这个界面的主人是谁?

产品_ 模型_ 界面_ Name

/模块/产品/模型/界面/名称/php

为什么?

这样你就能很容易地看到谁拥有创建该模型所使用的模型。

但是,如果您在谈论通用界面,那么您必须创建一个图书馆

/图书馆/ MyApplication/MyApplication/Models/Interface/Name.php /图书馆/ MyApplication/MyApplication/Models/Interface/Name.php / 图书馆/ MyApplication/MyApplication/Models/Interface/

如果您使用通用界面, 您需要将自动装入配置到您的靴套

我刚把它们放到图书馆的界面目录中, 这样他们就不会把模型目录弄乱。 我在我的图书馆里使用一个结构, 模拟 ZF 1.x 应用结构 :

/library
    /namespace
        /Application
            /Controller
                /Plugin
            /Interface
            /Model
                /Entity
                    /Abstract.php
                /Mapper
                    /Abstract.php
            /Resource
            /View
                /Helper

我知道它有点深,有点忙,但它使我保持组织。当我改成ZF2时,我必须重新评价以实施命名空间。





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签