简体   繁体   English

如何将整个项目嵌入到 phar 文件中?

[英]How to embed a whole project into a phar file?

I have my index.php that uses a class inside a php library (including folders, classes, subclasses) etc..我有我的index.php ,它使用 php 库中的一个类(包括文件夹、类、子类)等。

my index.php uses that whole library我的 index.php 使用了整个库

...
include("Classes/Crawler.php");
$crawl = new Crawler(); // 
...
  1. Is there a simple command line to create the phar files that includes all content inside Classes ?是否有一个简单的命令行来创建包含 Classes 中所有内容的 phar 文件?
  2. Do I need then to modify content of files so I can use index.php as it was ?我是否需要修改文件的内容,以便我可以使用 index.php ?

My goal is to distribute 2 files (index.php and Crawler.phar) without having to changing the source code我的目标是分发 2 个文件(index.php 和 Crawler.phar)而无需更改源代码

I use phing's pharpackage task to build my phar files, see https://github.com/cweiske/phorkie/blob/master/build.xml#L82 for an example.我使用 phing 的pharpackage任务来构建我的 phar 文件,示例参见https://github.com/cweiske/phorkie/blob/master/build.xml#L82

But apart from that, you can write your own script (it's easy; see the examples in the PHP manual).但除此之外,您还可以编写自己的脚本(这很容易;请参阅PHP 手册中的示例)。


About using index.php as it was: You can do that as long as you enable file interception with Phar::interceptFileFuncs() .关于按原样使用index.php :只要您使用Phar::interceptFileFuncs()启用文件拦截,您就可以这样做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM