Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 10315

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>mapPhar for web-based phars. front controller for web applications</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="phar.unlinkarchive.html">Phar::unlinkArchive</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="class.phardata.html">PharData</a></div>
 <div class="up"><a href="class.phar.html">Phar</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="phar.webphar" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Phar::webPhar</h1>
  <p class="verinfo">(PHP &gt;= 5.3.0, PECL phar &gt;= 2.0.0)</p><p class="refpurpose"><span class="refname">Phar::webPhar</span> &mdash; <span class="dc-title">mapPhar for web-based phars. front controller for web applications</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-phar.webphar-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">final</span> <span class="modifier">public</span> <span class="modifier">static</span> <span class="type"><span class="type void">void</span></span> <span class="methodname"><strong>Phar::webPhar</strong></span>
    ([ <span class="methodparam"><span class="type">string</span> <code class="parameter">$alias</code></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$index</code><span class="initializer"> = &quot;index.php&quot;</span></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$f404</code></span>
   [, <span class="methodparam"><span class="type">array</span> <code class="parameter">$mimetypes</code></span>
   [, <span class="methodparam"><span class="type"><a href="language.types.callable.html" class="type callable">callable</a></span> <code class="parameter">$rewrites</code></span>
  ]]]]] )</div>

  <p class="para rdfs-comment">
    <span class="function"><a href="phar.mapphar.html" class="function">Phar::mapPhar()</a></span> for web-based phars.  This method parses
   <var class="varname"><var class="varname"><a href="reserved.variables.server.html" class="classname">$_SERVER['REQUEST_URI']</a></var></var> and routes a request from a web
   browser to an internal file within the phar archive.  In essence, it simulates
   a web server, routing requests to the correct file, echoing the correct headers
   and parsing PHP files as needed.  This powerful method is part of what makes it easy
   to convert an existing PHP application into a phar archive.  Combined with
    <span class="function"><a href="phar.mungserver.html" class="function">Phar::mungServer()</a></span> and  <span class="function"><a href="phar.interceptfilefuncs.html" class="function">Phar::interceptFileFuncs()</a></span>,
   any web application can be used unmodified from a phar archive.
  </p>
  <p class="para">
    <span class="function"><strong>Phar::webPhar()</strong></span> should only be
   called from the stub of a phar archive (see <a href="phar.fileformat.stub.html" class="link">here</a>
   for more information on what a stub is).
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-phar.webphar-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>

    <dt>

     <span class="term"><em><code class="parameter">alias</code></em></span>
     <dd>

      <p class="para">
       The alias that can be used in <em>phar://</em> URLs to
       refer to this archive, rather than its full path.
      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">index</code></em></span>
     <dd>

      <p class="para">
       The location within the phar of the directory index.
      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">f404</code></em></span>
     <dd>

      <p class="para">
       The location of the script to run when a file is not found.  This
       script should output the proper HTTP 404 headers.
      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">mimetypes</code></em></span>
     <dd>

      <p class="para">
       An array mapping additional file extensions to MIME type.
       If the default mapping is sufficient, pass an empty array.
       By default, these extensions are mapped to these MIME types:
       <div class="example-contents">
        <div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$mimes&nbsp;</span><span style="color: #007700">=&nbsp;array(<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'phps'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">Phar</span><span style="color: #007700">::</span><span style="color: #0000BB">PHPS</span><span style="color: #007700">,&nbsp;</span><span style="color: #FF8000">//&nbsp;pass&nbsp;to&nbsp;highlight_file()<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'c'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'text/plain'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'cc'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'text/plain'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'cpp'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'text/plain'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'c++'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'text/plain'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'dtd'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'text/plain'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'h'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'text/plain'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'log'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'text/plain'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'rng'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'text/plain'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'txt'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'text/plain'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'xsd'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'text/plain'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'php'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">Phar</span><span style="color: #007700">::</span><span style="color: #0000BB">PHP</span><span style="color: #007700">,&nbsp;</span><span style="color: #FF8000">//&nbsp;parse&nbsp;as&nbsp;PHP<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'inc'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">Phar</span><span style="color: #007700">::</span><span style="color: #0000BB">PHP</span><span style="color: #007700">,&nbsp;</span><span style="color: #FF8000">//&nbsp;parse&nbsp;as&nbsp;PHP<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'avi'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'video/avi'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'bmp'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'image/bmp'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'css'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'text/css'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'gif'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'image/gif'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'htm'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'text/html'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'html'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'text/html'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'htmls'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'text/html'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'ico'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'image/x-ico'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'jpe'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'image/jpeg'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'jpg'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'image/jpeg'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'jpeg'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'image/jpeg'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'js'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'application/x-javascript'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'midi'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'audio/midi'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'mid'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'audio/midi'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'mod'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'audio/mod'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'mov'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'movie/quicktime'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'mp3'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'audio/mp3'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'mpg'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'video/mpeg'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'mpeg'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'video/mpeg'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'pdf'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'application/pdf'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'png'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'image/png'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'swf'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'application/shockwave-flash'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'tif'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'image/tiff'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'tiff'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'image/tiff'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'wav'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'audio/wav'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'xbm'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'image/xbm'</span><span style="color: #007700">,<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #DD0000">'xml'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'text/xml'</span><span style="color: #007700">,<br />);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
       </div>

      </p>
     </dd>

    </dt>

    <dt>

     <span class="term"><em><code class="parameter">rewrites</code></em></span>
     <dd>

      <p class="para">
       The rewrites function is passed a string as its only parameter and must return a <span class="type"><a href="language.types.string.html" class="type string">string</a></span> or <strong><code>FALSE</code></strong>.
      </p>
      <p class="para">
       If you are using fast-cgi or cgi then the parameter passed to the function is the value of the 
       <var class="varname"><var class="varname"><a href="reserved.variables.server.html" class="classname">$_SERVER['PATH_INFO']</a></var></var> variable. Otherwise, the parameter passed to the function is the value
       of the <var class="varname"><var class="varname"><a href="reserved.variables.server.html" class="classname">$_SERVER['REQUEST_URI']</a></var></var> variable.
      </p>
      <p class="para">
       If a string is returned it is used as the internal file path. If <strong><code>FALSE</code></strong> is returned then webPhar() will
       send a HTTP 403 Denied Code.
      </p>
     </dd>

    </dt>

   </dl>

  </p>

 </div>

 <div class="refsect1 returnvalues" id="refsect1-phar.webphar-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   No value is returned.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-phar.webphar-errors">
  <h3 class="title">Errors/Exceptions</h3>
  <p class="para">
   Throws <a href="class.pharexception.html" class="classname">PharException</a> when unable to open the internal
   file to output, or if
   called from a non-stub.  If an invalid array value is passed into
   <em><code class="parameter">mimetypes</code></em> or an invalid callback is passed into <em><code class="parameter">rewrites</code></em>, then
   <a href="class.unexpectedvalueexception.html" class="classname">UnexpectedValueException</a> is thrown.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-phar.webphar-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-704">
    <p><strong>Example #1 A  <span class="function"><strong>Phar::webPhar()</strong></span> example</strong></p>
    <div class="example-contents"><p>
     With the example below, the created phar will display <em>Hello World</em>
     if one browses to <em>/myphar.phar/index.php</em> or to
     <em>/myphar.phar</em>, and will display the source of
     <em>index.phps</em> if one browses to <em>/myphar.phar/index.phps</em>.
    </p></div>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;creating&nbsp;the&nbsp;phar&nbsp;archive:<br /></span><span style="color: #007700">try&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$phar&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">Phar</span><span style="color: #007700">(</span><span style="color: #DD0000">'myphar.phar'</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$phar</span><span style="color: #007700">[</span><span style="color: #DD0000">'index.php'</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #DD0000">'&lt;?php&nbsp;echo&nbsp;"Hello&nbsp;World";&nbsp;?&gt;'</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$phar</span><span style="color: #007700">[</span><span style="color: #DD0000">'index.phps'</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #DD0000">'&lt;?php&nbsp;echo&nbsp;"Hello&nbsp;World";&nbsp;?&gt;'</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$phar</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setStub</span><span style="color: #007700">(</span><span style="color: #DD0000">'&lt;?php<br />Phar::webPhar();<br />__HALT_COMPILER();&nbsp;?&gt;'</span><span style="color: #007700">);<br />}&nbsp;catch&nbsp;(</span><span style="color: #0000BB">Exception&nbsp;$e</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;handle&nbsp;error&nbsp;here<br /></span><span style="color: #007700">}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-phar.webphar-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"> <span class="function"><a href="phar.mungserver.html" class="function" rel="rdfs-seeAlso">Phar::mungServer()</a> - Defines a list of up to 4 $_SERVER variables that should be modified for execution</span></li>
    <li class="member"> <span class="function"><a href="phar.interceptfilefuncs.html" class="function" rel="rdfs-seeAlso">Phar::interceptFileFuncs()</a> - instructs phar to intercept fopen, file_get_contents, opendir, and all of the stat-related functions</span></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="phar.unlinkarchive.html">Phar::unlinkArchive</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="class.phardata.html">PharData</a></div>
 <div class="up"><a href="class.phar.html">Phar</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>