PHP方法使用FTP传输整个目录?

发布于 2024-08-16 07:50:37 字数 428 浏览 6 评论 0原文

我一直在尝试想出一种方法来为我正在构建的 cms 构建自动更新系统,该系统可能会安装在许多服务器上(可能具有不同的配置)。我想出的是将上传到我的服务器的当前版本保留在预定目录中。然后让分布式系统每隔一段时间检查一次该目录(在远程服务器上)以查看是否已上传新版本。如果上传的版本号大于特定系统的版本号,则会提示管理员更新。然后文件将通过 FTP 复制到 tmp 目录中,然后从 tmp 复制以替换每个文件的旧版本。然后删除tmp目录,并增加系统版本号。

问题是我还没有找到通过 PHP FTP 传输整个目录的方法。我知道我可以压缩它并以这种方式传输它,但我还没有找到在各种服务器环境中解压缩文件的可靠方法。

我知道我可以编写自己的方法,该方法将只遍历每个目录并一次传输每个文件,这很好。我只是想知道是否有人已经写过类似的内容,或者在我深入研究之前是否有人知道该问题的替代解决方案。

感谢您的帮助!

I've been trying to come up with a way to build an automatic update system for a cms that I'm building that will potentially be installed on numerous servers (likely with different configurations). What I've come up with is to keep a current version uploaded to my server in a predetermined directory. Then have the distributed systems check that directory (on a remote server) once every so often to see if a new version has been uploaded. If the version number of the uploaded version is greater than the one that particular system has, it will prompt the admin to update. Then the files will be copied via FTP into a tmp directory, then will be copied from tmp to replace the older versions of each file. then the tmp directory is deleted, and the systems version number is increased.

THe problem with this, is that I haven't found a way to transfer whole directories via PHP FTP. I know I can zip it and transfer it that way, but I haven't found a reliable way to unzip files in various server environments.

I know I can write my own method that will just go through each directory and transfer over each file one at a time, which is fine. I just wanted to know if someone else had already written something to this effect, or if someone knew of an alternate solution to this problem before I dive into it.

Thanks for your help!

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

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

发布评论

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

评论(2

小清晰的声音 2024-08-23 07:50:37

为什么不发送目录,而是压缩文件夹以节省带宽和时间?然后在目标服务器上解压缩。 已删除,因为它不是 OP 的选项

您可以使用 PHAR 为您的应用程序部署存档(如果您想成为前沿现代)

或者您可以为 < a href="http://phing.info/trac/" rel="nofollow noreferrer">Phing 从您的服务器获取文件。您甚至可以从 SVN 进行签出,而不是将构建放在目录中。

Instead of sending a directory, why not zip the folder to save bandwidth and time? Then unzip on the destination servers. deleted since it was not an option for the OP

You could use PHAR archives for your app deployment (if you want to be bleeding-edge modern)

Or you could write an update script for Phing that gets the files from your server. You could even do checkouts from SVN then, instead of placing the build in a directory.

梦纸 2024-08-23 07:50:37

尝试使用 exec() 从命令行运行 lftp:

/usr/bin/lftp -e 'o ftp://ftp.example.com/path/to/remote/directory &&镜像 --verbose &&退出'

Try using exec() to run lftp from the command line:

/usr/bin/lftp -e 'o ftp://ftp.example.com/path/to/remote/directory && mirror --verbose && quit'

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