将 php 框架集成到现有的 php 应用程序中是不是一个好主意?

发布于 2024-10-04 00:04:50 字数 757 浏览 5 评论 0原文

我正在开发一个大型 php 网站,目前不使用任何框架。我的大问题是,随着时间的推移,慢慢尝试将框架融入应用程序是否明智,例如在创建的新部分和更新的旧部分中?

例如,所有页面都直接通过 url 提供服务,其中有几十个页面看起来像这样,

//monitoring_projet.php
<?php
session_start();
require_once($_SERVER['DOCUMENT_ROOT'].'/include/header.php');
require_once($_SERVER['DOCUMENT_ROOT'].'/include/config_ats.php');
$page_link = 'monitoring_projet.php';
?>

<div id="content" style="padding-left:10px;margin:0 10px">
<br />
<?php
include($_SERVER['DOCUMENT_ROOT'].'/include/gestion_projet_entreprise.php')
?>
</div>

<?php require_once($_SERVER['DOCUMENT_ROOT'].'/include/footer.php'); ?>

我一直在 Zend Framework 上阅读,作为我选择的 php 框架毒药。尝试使用 ZF 来引导应用程序并将所有这些通用代码放到一个地方是个好主意吗?或者在这一点上添加一个框架会带来比其价值更多的麻烦吗?

I'm working on a large php site that currently does not use any framework. My big question would be, is it advisable to slowly try to work a framework into the application over time, such as in new parts that are created and older parts as they are updated?

For example, all pages are served directly by url, and dozens of them look like this

//monitoring_projet.php
<?php
session_start();
require_once($_SERVER['DOCUMENT_ROOT'].'/include/header.php');
require_once($_SERVER['DOCUMENT_ROOT'].'/include/config_ats.php');
$page_link = 'monitoring_projet.php';
?>

<div id="content" style="padding-left:10px;margin:0 10px">
<br />
<?php
include($_SERVER['DOCUMENT_ROOT'].'/include/gestion_projet_entreprise.php')
?>
</div>

<?php require_once($_SERVER['DOCUMENT_ROOT'].'/include/footer.php'); ?>

I've been reading up on Zend Framework as my php framework poison of choice. Would it be a good idea to try and use ZF just to bootstrap the app and get all this common code into one place? Or is adding a framework into the mix going to cause more headaches than its worth at this point?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

恕我直言,将框架插入到这样的项目中只会带来麻烦;我认为配置、依赖管理等将是一个真正的麻烦。

我认为这里最有效的方法是创建一个单独的空白框架项目,根据您的项目规范定义视图、控制器和模型,然后插入当前页面中的代码,在控制器之间分配代码并适当地查看。这样,您就可以将配置和支持类迁移到框架中,而无需尝试改变框架以适应您的项目。

IMHO, plugging in a framework into a project like that just spells trouble; I imagine that configuration, dependency management and such would be a real hassle.

The approach I think would work best here is to make a separate blank framework project, define the views, controllers and models according to your project specs, then plug in the code from your current pages, distributing code among controllers and view appropriately. That way, you can migrate configuration and support classes into the framework without trying to bend the framework to suit your project.

戏舞 2024-10-11 00:04:50

这完全取决于您的技能以及您尝试转换为 Zend 的系统。

在我现在所做的工作中,我们正在慢慢地添加 Zend Framework 库,进展非常顺利。

如果您想随着时间的推移将整个网站替换为 Zend Framework(适应 MVC 模式),那就是另一回事了。在这种情况下,你会遇到各种各样的麻烦。您突然被迫使用当前代码无法处理的某种设计模式。那时你会感到头疼,因为你很快就会失去对自己正在做的事情的概览。不要慢慢地做,而是一步一步地做。它也可能会让您头痛,但只会持续很短的时间。

祝你好运!

It completely depends on your skills and on the system you're trying to convert to Zend.

At the job I'm working right now, we are slowly adding Zend Framework libraries in it, which is going pretty well.

If you want to replace your complete website with Zend Framework (ajusting to the MVC pattern) over time, it is a different story. In that case you get all kinds of trouble. You are suddenly forced to use a certain design pattern your current code is unable to deal with. At that point you will get headaches cause you will soon lose the overview of what you're doing. Don't do that slowly, but do it in one step. It could give you headaches too, but only for a short time.

Good luck!

笨笨の傻瓜 2024-10-11 00:04:50

我目前在一家公司工作,该公司正在将 Zend Framework 引入其当前的代码库。它造成了一些问题,但现在正在慢慢好转。正如 Krof DraKula 提到的,依赖管理可能是一个问题,而配置会引起一些麻烦。

我们有一个 DAO、BO、VO 模式,效果很好,但使用起来却变得很混乱。我们正在慢慢地将类迁移到 ZF stylee。如果你真的想这样做,我建议你慢慢来,让两种风格并排运行。起初,我们将 Zend Framework 模块与遗留的东西一起运行,只有当它完美运行时,我们才开始迁移和重构。

如果您有技能和时间来迁移,我相信您不会后悔。

I currently work for a company that is introducing Zend Framework to its current code base. It has caused problems but is now slowly getting better. As Krof DraKula mentions, dependency management can be a problem and configuration caused some headaches.

We had a DAO, BO, VO pattern that worked well but was getting messy to work with. We are slowly migrating classes over to ZF stylee. If you are serious about doing this I would recommend going slowly, get the two styles running side by side. At first we ran Zend Framework modules alongside our legacy stuff and only when that was working flawlessly did we start migrating and refactoring.

If you have the skill and the time to migrate you won't regret it, I'm sure.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文