模块化PHP [英] Modular PHP

查看:122
本文介绍了模块化PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计们


我即将为我的公司编写一些后端软件。我想要一个系统

,我可以创建发票,客户等...我可以做到这一点没问题。然而

我想用模块写它,以便将来可以扩展。


像其他人一样可以为它编写一个模块,它可以直接插入我的

系统。我无法找到一个在PHP中执行此操作的好方法。我在考虑

钩子什么的,但PHP不支持这个。


PHP 5有这样的东西吗?或者其他人是否知道一个好方法

用PHP 4做什么?


任何信息都赞赏。


谢谢

解决方案

Hayden Kirk apensétrèsfort:

嘿伙计们

我是即将为我的业务编写一些后端软件。我想要一个系统
我可以创建发票,客户等...我可以做到这一点没问题。但是
我想在模块中编写它,以便将来可以扩展。

像其他人一样可以为它编写一个模块,它可以直接插入我的
系统。我无法找到一个在PHP中执行此操作的好方法。我在考虑
钩子或什么,但PHP不支持这个。

PHP 5有这样的东西吗?或者其他人是否知道在PHP 4中使用它的好方法?

任何信息都赞赏。

谢谢




你有几种方法可以做到这一点,最糟糕的做法是简单地传递

给予eval()的b / b代码,但它恕我直言,这不是一件好事。


最好的PHP方法是实现一个objet加载器,所以你在一个类中编写你的
模块

,你的核心应用程序加载


< blockquote> object = new

" ModuleName";

当然可以替换为


object = new

Hey guys

I am about to write some back end software for my business. I want a system
that I can create invoices, clients etc... I can do this no problem. However
I want to write it in modules so its extendable in the future.

Like someone else can write a module for it and it can plug stright into my
system. I can''t figure out a good way to do this in php. I was thinking of
hooks or something, but PHP does not support this.

Does PHP 5 have anything like this? Or does anyone else know a good way to
do it in PHP 4?

Any info appreciated.

Thanks

解决方案

Hayden Kirk a pensé très fort :

Hey guys

I am about to write some back end software for my business. I want a system
that I can create invoices, clients etc... I can do this no problem. However
I want to write it in modules so its extendable in the future.

Like someone else can write a module for it and it can plug stright into my
system. I can''t figure out a good way to do this in php. I was thinking of
hooks or something, but PHP does not support this.

Does PHP 5 have anything like this? Or does anyone else know a good way to
do it in PHP 4?

Any info appreciated.

Thanks



You have several ways to do it, the worst way to do it is simply pass
the
code given to an eval(), but it is not a really good thing IMHO.

The best "PHP" way is to implement an objet loader, so you write your
modules
in a class, and your core application loads it with a


object = new
"ModuleName";
which of course can be replaced by a


object = new


这篇关于模块化PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆