PHP: Phar::setDefaultStub - Manual (original) (raw)

(PHP 5 >= 5.3.0, PHP 7, PHP 8, PECL phar >= 2.0.0)

Phar::setDefaultStub — Used to set the PHP loader or bootstrap stub of a Phar archive to the default loader

Parameters

index

Relative path within the phar archive to run if accessed on the command-line

webIndex

Relative path within the phar archive to run if accessed through a web browser

Return Values

Always returns [true](reserved.constants.php#constant.true).

Changelog

Version Description
8.4.0 Phar::setDefaultStub() now has a tentative return of true.
8.0.0 webIndex is nullable now.

Examples

Example #1 A Phar::setDefaultStub() example

<?php try { $phar = new Phar('myphar.phar'); $phar->setDefaultStub('cli.php', 'web/index.php'); // this is the same as: // <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>p</mi><mi>h</mi><mi>a</mi><mi>r</mi><mo>−</mo><mo>&gt;</mo><mi>s</mi><mi>e</mi><mi>t</mi><mi>S</mi><mi>t</mi><mi>u</mi><mi>b</mi><mo stretchy="false">(</mo></mrow><annotation encoding="application/x-tex">phar-&gt;setStub(</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord mathnormal">p</span><span class="mord mathnormal">ha</span><span class="mord mathnormal" style="margin-right:0.02778em;">r</span><span class="mord">−</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">&gt;</span><span class="mspace" style="margin-right:0.2778em;"></span></span><span class="base"><span class="strut" style="height:1em;vertical-align:-0.25em;"></span><span class="mord mathnormal">se</span><span class="mord mathnormal">tSt</span><span class="mord mathnormal">u</span><span class="mord mathnormal">b</span><span class="mopen">(</span></span></span></span>phar->createDefaultStub('cli.php', 'web/index.php')); } catch (Exception $e) { // handle errors } ?>

See Also

Found A Problem?

There are no user contributed notes for this page.