PHP 从 Mercurial 存储库中获取并解压代码?
我在 bitbucket 上设置了一个私有存储库,其中包含我正在开发的网站项目的代码。该网站位于另一家公司的网络服务器上,其中有一个受密码保护的目录(例如playground
),我在上线之前用它进行测试。 现在我知道我可以设置一个可以发出 HTTP POST 请求的 bitbucket 服务,并且我还被告知我可以在网络服务器上设置一个 PHP,它将从 bitbucket 获取存储库并将其解压到指定目录中。 正如您所猜到的那样,我正在寻找有关此 PHP 脚本的一些指示,以实现此目的。任何示例代码/教程/文章都会非常有帮助。
谢谢!
I have a private repository setup on bitbucket that has code for a website project that I am working on. The website sits on a web server with another company and has a password protected directory within it (eg. playground
) which I use for testing before making things live.
Now I know I can set up a bitbucket service that can make HTTP POST requests and I have also been told I can set up a PHP on the webserver that will go and grab the repository from bitbucket and untar it into the specified directory.
As you have rightly guessed, I am looking for some pointers on this PHP script that will do just this. Any example code/tutorial/articles would be most helpful.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你只需要让你的 PHP 得到一个像这样的 URL:
使用这样的库:
将两个 adium 替换为您的用户名和存储库名称。这将为您提供 .tar.gz,然后您可以使用 shell 命令或 http://php.net/manual/en/book.zlib.php 以及类似这样的内容:http://www.devshed.com/c/a/PHP/TAR-文件管理-With-PHP-Archive- Tar/
这是另一个执行相同操作的库: http://www.techrepublic.com/article/create-and-edit-tar-archives-dynamically-with-php-and-pear/6161314
You just need to have your PHP get a URL like this:
using a library like these:
substituting your username and repository name for both adiums. That will get you the .tar.gz and then you can open it up using either a shell command or a combination of http://php.net/manual/en/book.zlib.php and something like this: http://www.devshed.com/c/a/PHP/TAR-File-Management-With-PHP-Archive-Tar/
Here's another library that does the same thing: http://www.techrepublic.com/article/create-and-edit-tar-archives-dynamically-with-php-and-pear/6161314
可以直接在php中使用shell命令。使用这个:
shell_exec();
例如你想删除某个文件,在 UNIX 服务器中你可以这样调用它:
shell_exec('rm test.txt')';
如果你在 Windows 上运行,你可以使用 MS-DOS 命令,不过除了 dir 之外我不太熟悉它,哈哈。
希望这有帮助。
You can use shell command directly in php. Use this:
shell_exec(<shell_command>);
For example you want to delete some file, in UNIX server you can call it this way:
shell_exec('rm test.txt')';
If you are running on Windows, you can use MS-DOS command, tho I am not really familiar with it aside of dir, lol.
Hope this helps.