mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-29 07:18:55 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@256055 c90b9560-bf6c-de11-be94-00142212c4b1
145 lines
3.7 KiB
XML
145 lines
3.7 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision: 1.3 $ -->
|
|
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="phar.setstub">
|
|
<refnamediv>
|
|
<refname>Phar::setStub</refname>
|
|
<refpurpose>Used to set the PHP loader or bootstrap stub of a Phar archive</refpurpose>
|
|
</refnamediv>
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>void</type><methodname>Phar::setStub</methodname>
|
|
<methodparam><type>string</type><parameter>stub</parameter></methodparam>
|
|
</methodsynopsis>
|
|
&phar.write;
|
|
|
|
|
|
<para>
|
|
This method is used to add a PHP bootstrap loader stub to a new Phar archive, or
|
|
to replace the loader stub in an existing Phar archive.
|
|
</para>
|
|
<para>
|
|
The loader stub for a Phar archive is used whenever an archive is included directly
|
|
as in this example:
|
|
</para>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
include 'myphar.phar';
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
<para>
|
|
The loader is not accessed when including a file through the <literal>phar</literal>
|
|
stream wrapper like so:
|
|
</para>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
include 'phar://myphar.phar/somefile.php';
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>stub</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
A string or an open stream handle to use as the executable stub for this
|
|
phar archive.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
<refsect1 role="errors">
|
|
&reftitle.errors;
|
|
<para>
|
|
<classname>UnexpectedValueException</classname> is thrown if
|
|
<link linkend="ini.phar.readonly">phar.readonly</link> is enabled
|
|
in php.ini.
|
|
<classname>PharException</classname> is thrown if any problems are encountered
|
|
flushing changes to disk.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>A <function>Phar::setStub</function> example</title>
|
|
<para>
|
|
</para>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
try {
|
|
$p = new Phar(dirname(__FILE__) . '/brandnewphar.phar', 0, 'brandnewphar.phar');
|
|
$p['a.php'] = '<?php var_dump("Hello");';
|
|
$p->setStub('<?php var_dump("First"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>');
|
|
include 'phar://brandnewphar.phar/a.php';
|
|
var_dump($p->getStub());
|
|
$p['b.php'] = '<?php var_dump("World");';
|
|
$p->setStub('<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>');
|
|
include 'phar://brandnewphar.phar/b.php';
|
|
var_dump($p->getStub());
|
|
} catch (Exception $e) {
|
|
echo 'Write operations failed on brandnewphar.phar: ', $e;
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
string(5) "Hello"
|
|
string(82) "<?php var_dump("First"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>"
|
|
string(5) "World"
|
|
string(83) "<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>"
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>Phar::getStub</function></member>
|
|
<member><function>Phar::createDefaultStub</function></member>
|
|
</simplelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"../../../../manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|