如何处理一个 CakePHP Web 应用程序的多个安装的部署和更新?

发布于 2024-11-29 23:26:26 字数 534 浏览 1 评论 0原文

我使用 CakePHP 制作了一个简单的 CMS 来处理少量(但不断增长)的网站。随着我定期向自己机器上的开发版本添加功能,CMS 不断发展。

我使用SVN来追踪这个开发版本的演变,仅此而已。为了制作一个新网站,我基本上会复制/粘贴 dev 文件夹并修改必要的文件,然后再通过 FTP 上传新网站。

最后一个问题是,每个网站安装都是独立的,如果我想向现有网站添加一些新功能,我必须手动复制文件。

另一个问题是,一些网站由于特定需求而修改了 CMS 版本:某些控制器类具有本地版本上不存在的特定方法。

总结一下:

  • 我有一个定期发展的基础 CakePHP 应用程序
  • 该应用程序的多个版本(=网站)已安装在不同的服务器上
  • 一些网站包含基本版本中不存在的自定义代码
  • 我希望能够轻松更新所有当我改进基本应用程序时,当前和未来的网站,而不破坏一些可能的特定部分

知道这是一个 CakePHP 应用程序,您会做什么?我应该如何更改我的代码以同时管理核心和特定代码?

提前致谢!

I made a simple CMS with CakePHP to handle a small (but growing) number of websites. The CMS is constantly evolving as I regularly add features to a development version on my own machine.

I use SVN to trace the evolution of this development version, and that's pretty much it. To make a new website, I basically copy/paste the dev folder and modify the necessary files before uploading the new website by FTP.

One problem is in the end, every website installation is independent and if I want to add some new features to existing websites, I have to copy files by hand.

Another problem is that some websites have modified versions of the CMS because of specific needs: some controller classes have specific methods not present on the local version.

To sum it up:

  • I have one base CakePHP app regularly evolving
  • There are multiple versions (=websites) of this app already installed on different servers
  • Some websites have custom code included not present in the base version
  • I want to be able to easily update all the present and future websites when I improve the base app, without breaking some possible specific parts

Knowing it's a CakePHP app, what would you do? How should I change my code to manage at the same time the core and the specific code?

Thanks in advance!

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

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

发布评论

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

评论(2

得不到的就毁灭 2024-12-06 23:26:26

...某些控制器类具有本地版本中不存在的特定方法。

您还可以考虑在每个目录中设置其他类路径您的网站应用程序。您可以告诉 CakePHP 完全检查其他目录以查找当前应用程序中丢失的文件。例如,您可以具有以下目录结构:

/app1 - a standard client's website application
/app2
/app3 - a custom client's website application (with custom controller)
/core - the core CMS application
/cake

通过将以下内容添加到 /appN/config/bootstrap.php 文件中,您可以告诉 CakePHP 在 /core/controllers 中查找控制器 如果它在当前应用程序中找不到它要查找的内容。

App::build(array(
    'controllers' => array(ROOT . DS . 'core' . DS . 'controllers' . DS),
));

例如,这将允许您将所有 CMS 控制器放入 /core/controllers 中并删除所有 /appN/controllers 目录。仅当客户端需要自定义控制器(即上面的 /app3)时,您才会创建控制器目录,复制特定控制器并进行修改(添加方法等)。

(这是 Wildflower CMS 的开发人员采用的方法 - 请注意 /wildflower目录。)

... some controller classes have specific methods not present on the local version.

You might also consider the option of setting up additional class paths within each of your website applications. You can tell CakePHP to check other directories entirely for files missing from the current application. For example, you could have the following directory structure:

/app1 - a standard client's website application
/app2
/app3 - a custom client's website application (with custom controller)
/core - the core CMS application
/cake

By adding the following to your /appN/config/bootstrap.php files, you are telling CakePHP to look for controllers in /core/controllers if it can't find one it's looking for in the current application.

App::build(array(
    'controllers' => array(ROOT . DS . 'core' . DS . 'controllers' . DS),
));

This would, for example, allow you to put all your CMS controllers in /core/controllers and delete all your /appN/controllers directories. Only where a client needed a controller customized (ie. /app3 above) would you create a controllers directory, copy the specific controller across and make modifications (adding methods and such).

(This is the approach the developer of Wildflower CMS took - note the /wildflower directory.)

爱要勇敢去追 2024-12-06 23:26:26

使用版本控制软件(如 SVN)可能会帮您解决问题。您工作的每个网站都可以是遵循主开发分支的一个分支。每次您进行要应用于每个站点的更改时,您都会更新主分支,然后让每个子分支从主分支导入更改。

请注意,我更习惯 Git 的工作方式,因此这种情况在 Git 中可能比在 SVN 中效果更好,ymmv。

Using version control software (like SVN) would probably do the trick for you. Each website you work on could be a branch that follows the main branch of development. Every time you make a change that you want to apply to every site, you'd update the main branch and then have every sub branch import the changes from the main branch.

Mind you, I'm more used to how Git works, so this scenario might work better in Git than in SVN, ymmv.

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