[英]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(); //
...
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.