7

I'm planning on creating a bunch of PHP scripts in a phar archive (for easy deployment) and allowing it to self-update from a known repository.

How should a phar archive, on a live website, update itself? Not update its contents, but just replacing itself (from a new.phar previously downloaded to /tmp or something) would be enough.

I'm specifically concerned about pitfalls on "replacing myself" in PHP, also considering requests could be underway (the script will primarily be called from the web, by AJAX).

4

2 回答 2

2

您可以检查作曲家如何自我更新:

https://github.com/composer/composer/blob/master/src/Composer/Command/SelfUpdateCommand.php

但就像@OddEssay 所说,使用作曲家作为包管理器可能会更好。

于 2013-11-05T23:29:27.510 回答
2

检查Distributing CLI PHP App with Ease 文章

还提到了 PHP-Phar-Update 包,它处理 PHAR 自我更新。

对于实现示例,您可以查看PhpDocumentor 的 Self-update command

于 2014-12-29T23:16:49.143 回答