You need to do this before referencing files within the archive using the phar:// stream wrapper. 您需要在归档内引用文件之前使用phar://流包装器执行初始化。
The Phar extension is based on a similar concept, but it is designed more for the Web environment of PHP. Phar扩展正是基于类似的理念,但是在设计时主要针对PHP的Web环境。
We have now created a Phar archive, which can be used by any PHP application. 我们现在已经创建了一个Phar归档,它可以用于任何PHP应用程序。
The Phar object uses the ArrayAccess SPL object to allow accessing the contents of the archive as an array, so it opens up many ways of adding files to the archive. Phar对象使用ArrayAccessSPL对象,允许以数组的形式访问归档内容,因此提供了许多方法来向归档添加文件。
The Phar:: mapPhar() method call shown above initializes the Phar archive by reading the manifest. 上面所示的Phar::mapPhar()方法调用通过读取清单文件(manifest)对Phar归档执行初始化。
Running a PHP application from a Phar archive 从Phar归档运行PHP应用程序
This setting is not required to open or reference files within a Phar archive within PHP. 在PHP的Phar归档内打开和引用文件时不需要使用到该设置。
Next, you'll need to define the file stub, which is the first code called when the Phar file is loaded. 接下来,将需要定义文件存根(stub),这是在加载Phar文件时首先调用的代码。
A second optional argument to the Phar:: createDefaultStub() method allows you to include a different file if the Phar is loaded from a Web server. 如果从Web服务器加载Phar,Phar::createDefaultStub()方法的第二个可选参数允许包含一个不同的文件。
The second include uses the stream wrapper to open the Phar archive and only includes the specified file inside the archive. 第二个include使用流包装器打开Phar归档并且仅在归档中包括指定的文件。
How to add this stub to your Phar archive depends upon what archive format you are using. 如何将这个文件存根Phar添加到Phar归档取决于所使用的归档的格式。
This is especially true if you have used the native Phar-based archive format. 如果使用的是原生的基于Phar的归档格式,这一点尤其明显。
One way is by using the Phar:: buildFromDirectory() method, which will walk through a specified directory and add the files within it. 一种方法就是使用Phar::buildFromDirectory()方法,该方法将遍历指定的目录并添加其中的文件。
In this case, you don't even need the Phar extension installed, since PHP can natively load the file and extract its contents. 在这种情况下,您甚至不需要安装Phar扩展,因为PHP天生就可以加载文件并提取文件内容。
Integrating Phar archive code in your application 在应用程序中集成Phar归档代码
The Phar:: buildFromIterator() method accepts the iterator object itself as the sole argument. buildFromIterator()方法接受迭代器对象本身作为惟一的参数。
The object reference will allow you to control all aspects of the Phar archive. 对象引用将允许您控制Phar归档的所有方面。
By default, the Phar created will use the native Phar-based archive format. 默认情况下,创建的Phar将使用原生的基于Phar的归档格式。
The concept of Phar archives come from Java ™ technology's JAR archives, which allow you to package an application within a single file containing everything needed to run the application. Phar归档的概念来自Java™技术的JAR归档,它允许使用单个文件打包应用程序,这个文件中包含运行应用程序所需的所有东西。
Any references to files in the application need to be changed to use the phar:// stream wrapper with the name of the archive, as shown in the previous section. 应用程序中的任何文件引用都需要修改为同时使用phar://流包装器和归档名,如前面小节所示。
There are several steps needed to create a Phar file. 创建Phar文件需要执行若干步骤。
For Phar-based archives, use the Phar:: setStub() method, which accepts the sole parameter of the PHP code to put in the stub as a string. 对于基于Phar的归档,使用Phar::setStub()方法,它将接受PHP代码的惟一参数,并以字符串形式放入存根中。
OBJECTIVE: To analysis the micro-policy demand of medical institutions about carrying on qualified phar ˉ maceutical service. 目的:探求我国医疗机构开展药学服务对政策的需求。
The advantages of 386/ 486 computer's protected model and virtual model, and the mechanism and method for realizing the protected model are discussed in this paper. The software tools "phar Lap 386| DOS-Extender" based on the protected model is also introduced. 讨论了386/486微机保护模式、虚拟模式的优点和实现保护模式的原理及方法、对基于保护模式的软件工具pharLap386DOS-Extender作了简要的介绍。
Our results proved that CC sperm has integrated its genetic materials into ASCC and PHAR genomes when it stimulates the development of triploidy ova, causing the economic trait superiority of ASCC and PHAR. 研究结果证明在精子刺激卵发育时,也将一部分遗传物质整合进了卵细胞核,使其后代经济性状具有一定的优势。