Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 10312

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>Using Phar Archives: Introduction</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="phar.using.html">Using Phar Archives</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="phar.using.stream.html">Using Phar Archives: the phar stream wrapper</a></div>
 <div class="up"><a href="phar.using.html">Using Phar Archives</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="phar.using.intro" class="section">
 <h2 class="title">Using Phar Archives: Introduction</h2>
 <p class="para">
  Phar archives are similar in concept to Java JAR archives, but are tailored
  to the needs and to the flexibility of PHP applications.  A Phar archive is
  used to distribute a complete PHP application or library in a single file. A
  Phar archive application is used exactly like any other PHP application:
 </p>
 <div class="example-contents screen">
  <div class="cdata"><pre>
php coolapplication.phar
  </pre></div>
 </div>
 <p class="para">
  Using a Phar archive library is identical to using any other PHP library:
 </p>
 <p class="para">
  <div class="informalexample">
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">include&nbsp;</span><span style="color: #DD0000">'coollibrary.phar'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
 </p>
 <p class="para">
  The <em>phar</em> stream wrapper provides the core of the phar extension, and
  is explained in detail <a href="phar.using.stream.html" class="link">here</a>.
  The phar stream wrapper allows accessing the files within a phar archive using
  PHP&#039;s standard file functions  <span class="function"><a href="function.fopen.html" class="function">fopen()</a></span>,  <span class="function"><a href="function.opendir.html" class="function">opendir()</a></span>, and
  others that work on regular files.  The <em>phar</em> stream wrapper supports all
  read/write operations on both files and directories.
 </p>
 <p class="para">
  <div class="informalexample">
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">include&nbsp;</span><span style="color: #DD0000">'phar://coollibrary.phar/internal/file.php'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">header</span><span style="color: #007700">(</span><span style="color: #DD0000">'Content-type:&nbsp;image/jpeg'</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">//&nbsp;phars&nbsp;can&nbsp;be&nbsp;accessed&nbsp;by&nbsp;full&nbsp;path&nbsp;or&nbsp;by&nbsp;alias<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">file_get_contents</span><span style="color: #007700">(</span><span style="color: #DD0000">'phar:///fullpath/to/coollibrary.phar/images/wow.jpg'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
 </p>
 <p class="para">
  The <a href="class.phar.html" class="classname">Phar</a> class implements advanced functionality for accessing
  files and for creating phar archives.  The Phar class is explained in detail
  <a href="phar.using.object.html" class="link">here</a>.
 </p>
 <p class="para">
  <div class="informalexample">
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">try&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;open&nbsp;an&nbsp;existing&nbsp;phar<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$p&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">'coollibrary.phar'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;Phar&nbsp;extends&nbsp;SPL's&nbsp;DirectoryIterator&nbsp;class<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">foreach&nbsp;(new&nbsp;</span><span style="color: #0000BB">RecursiveIteratorIterator</span><span style="color: #007700">(</span><span style="color: #0000BB">$p</span><span style="color: #007700">)&nbsp;as&nbsp;</span><span style="color: #0000BB">$file</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;$file&nbsp;is&nbsp;a&nbsp;PharFileInfo&nbsp;class,&nbsp;and&nbsp;inherits&nbsp;from&nbsp;SplFileInfo<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">$file</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getFileName</span><span style="color: #007700">()&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">file_get_contents</span><span style="color: #007700">(</span><span style="color: #0000BB">$file</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getPathName</span><span style="color: #007700">())&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;&nbsp;</span><span style="color: #FF8000">//&nbsp;display&nbsp;contents;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">}<br />&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(isset(</span><span style="color: #0000BB">$p</span><span style="color: #007700">[</span><span style="color: #DD0000">'internal/file.php'</span><span style="color: #007700">]))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$p</span><span style="color: #007700">[</span><span style="color: #DD0000">'internal/file.php'</span><span style="color: #007700">]-&gt;</span><span style="color: #0000BB">getMetadata</span><span style="color: #007700">());<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;create&nbsp;a&nbsp;new&nbsp;phar&nbsp;-&nbsp;phar.readonly&nbsp;must&nbsp;be&nbsp;0&nbsp;in&nbsp;php.ini<br />&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;phar.readonly&nbsp;is&nbsp;enabled&nbsp;by&nbsp;default&nbsp;for&nbsp;security&nbsp;reasons.<br />&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;On&nbsp;production&nbsp;servers,&nbsp;Phars&nbsp;need&nbsp;never&nbsp;be&nbsp;created,<br />&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;only&nbsp;executed.<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">if&nbsp;(</span><span style="color: #0000BB">Phar</span><span style="color: #007700">::</span><span style="color: #0000BB">canWrite</span><span style="color: #007700">())&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$p&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">'newphar.tar.phar'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'newphar.tar.phar'</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;make&nbsp;this&nbsp;a&nbsp;tar-based&nbsp;phar&nbsp;archive,&nbsp;compressed&nbsp;with&nbsp;gzip&nbsp;compression&nbsp;(.tar.gz)<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$p&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$p</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">convertToExecutable</span><span style="color: #007700">(</span><span style="color: #0000BB">Phar</span><span style="color: #007700">::</span><span style="color: #0000BB">TAR</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">Phar</span><span style="color: #007700">::</span><span style="color: #0000BB">GZ</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;create&nbsp;transaction&nbsp;-&nbsp;nothing&nbsp;is&nbsp;written&nbsp;to&nbsp;newphar.phar<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;until&nbsp;stopBuffering()&nbsp;is&nbsp;called,&nbsp;although&nbsp;temporary&nbsp;storage&nbsp;is&nbsp;needed<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$p</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">startBuffering</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;add&nbsp;all&nbsp;files&nbsp;in&nbsp;/path/to/project,&nbsp;saving&nbsp;in&nbsp;the&nbsp;phar&nbsp;with&nbsp;the&nbsp;prefix&nbsp;"project"<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$p</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">buildFromIterator</span><span style="color: #007700">(new&nbsp;</span><span style="color: #0000BB">RecursiveIteratorIterator</span><span style="color: #007700">(new&nbsp;</span><span style="color: #0000BB">DirectoryIterator</span><span style="color: #007700">(</span><span style="color: #DD0000">'/path/to/project'</span><span style="color: #007700">)),&nbsp;</span><span style="color: #DD0000">'/path/to/'</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;add&nbsp;a&nbsp;new&nbsp;file&nbsp;via&nbsp;the&nbsp;array&nbsp;access&nbsp;API<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$p</span><span style="color: #007700">[</span><span style="color: #DD0000">'file1.txt'</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #DD0000">'Information'</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$fp&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">fopen</span><span style="color: #007700">(</span><span style="color: #DD0000">'hugefile.dat'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'rb'</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;copy&nbsp;all&nbsp;data&nbsp;from&nbsp;the&nbsp;stream<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$p</span><span style="color: #007700">[</span><span style="color: #DD0000">'data/hugefile.dat'</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">$fp</span><span style="color: #007700">;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">Phar</span><span style="color: #007700">::</span><span style="color: #0000BB">canCompress</span><span style="color: #007700">(</span><span style="color: #0000BB">Phar</span><span style="color: #007700">::</span><span style="color: #0000BB">GZ</span><span style="color: #007700">))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$p</span><span style="color: #007700">[</span><span style="color: #DD0000">'data/hugefile.dat'</span><span style="color: #007700">]-&gt;</span><span style="color: #0000BB">compress</span><span style="color: #007700">(</span><span style="color: #0000BB">Phar</span><span style="color: #007700">::</span><span style="color: #0000BB">GZ</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$p</span><span style="color: #007700">[</span><span style="color: #DD0000">'images/wow.jpg'</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">file_get_contents</span><span style="color: #007700">(</span><span style="color: #DD0000">'images/wow.jpg'</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;any&nbsp;value&nbsp;can&nbsp;be&nbsp;saved&nbsp;as&nbsp;file-specific&nbsp;meta-data<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$p</span><span style="color: #007700">[</span><span style="color: #DD0000">'images/wow.jpg'</span><span style="color: #007700">]-&gt;</span><span style="color: #0000BB">setMetadata</span><span style="color: #007700">(array(</span><span style="color: #DD0000">'mime-type'&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;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$p</span><span style="color: #007700">[</span><span style="color: #DD0000">'index.php'</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #0000BB">file_get_contents</span><span style="color: #007700">(</span><span style="color: #DD0000">'index.php'</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$p</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setMetadata</span><span style="color: #007700">(array(</span><span style="color: #DD0000">'bootstrap'&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">'index.php'</span><span style="color: #007700">));<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;save&nbsp;the&nbsp;phar&nbsp;archive&nbsp;to&nbsp;disk<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$p</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">stopBuffering</span><span style="color: #007700">();<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}&nbsp;catch&nbsp;(</span><span style="color: #0000BB">Exception&nbsp;$e</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'Could&nbsp;not&nbsp;open&nbsp;Phar:&nbsp;'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$e</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
 </p>
 <p class="para">
  In addition, verification of phar file contents can be done using any of the
  supported symmetric hash algorithms (MD5, SHA1, SHA256 and SHA512 if ext/hash is enabled)
  and using asymmetric public/private key signing using OpenSSL (new in Phar 2.0.0).  To
  take advantage of OpenSSL signing, you need to generate a public/private key pair, and
  use the private key to set the signature using
   <span class="function"><a href="phardata.setsignaturealgorithm.html" class="function">Phar::setSignatureAlgorithm()</a></span>.  In addition, the public key
  as extracted using this code:
  <div class="example-contents">
   <div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$public&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">openssl_get_publickey</span><span style="color: #007700">(</span><span style="color: #0000BB">file_get_contents</span><span style="color: #007700">(</span><span style="color: #DD0000">'private.pem'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">$pkey&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">''</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">openssl_pkey_export</span><span style="color: #007700">(</span><span style="color: #0000BB">$public</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$pkey</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
  </div>

  must be saved adjacent to the phar archive it verifies.  If the phar archive
  is saved as <em>/path/to/my.phar</em>, the public key must be saved
  as <em>/path/to/my.phar.pubkey</em>, or phar will be unable to verify
  the OpenSSL signature.
 </p>
 <p class="para">
  As of version 2.0.0, The <a href="class.phar.html" class="classname">Phar</a> class also provides 3 static methods,  <span class="function"><a href="phar.webphar.html" class="function">Phar::webPhar()</a></span>,
   <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> that are crucial
  to packaging up PHP applications designed for usage on regular filesystems and for web-based applications.
   <span class="function"><a href="phar.webphar.html" class="function">Phar::webPhar()</a></span> implements a front controller that routes HTTP calls to the correct
  location within the phar archive.   <span class="function"><a href="phar.mungserver.html" class="function">Phar::mungServer()</a></span> is used to modify the values of
  the <var class="varname"><var class="varname"><a href="reserved.variables.server.html" class="classname">$_SERVER</a></var></var> array to trick applications that process these values.
   <span class="function"><a href="phar.interceptfilefuncs.html" class="function">Phar::interceptFileFuncs()</a></span> instructs Phar to intercept calls to
   <span class="function"><a href="function.fopen.html" class="function">fopen()</a></span>,  <span class="function"><a href="function.file-get-contents.html" class="function">file_get_contents()</a></span>,  <span class="function"><a href="function.opendir.html" class="function">opendir()</a></span>, and
  all of the stat-based functions ( <span class="function"><a href="function.file-exists.html" class="function">file_exists()</a></span>,  <span class="function"><a href="function.is-readable.html" class="function">is_readable()</a></span> and so on) and
  route all relative paths to locations within the phar archive.
 </p>
 <p class="para">
  As an example, packaging up a release of the popular phpMyAdmin application for use as a phar archive requires
  only this simple script and then <em>phpMyAdmin.phar.tar.php</em> can be accessed as a regular file
  from your web server after modifying the user/password:
 </p>
 <p class="para">
  <div class="informalexample">
   <div class="example-contents">
    <div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">@</span><span style="color: #0000BB">unlink</span><span style="color: #007700">(</span><span style="color: #DD0000">'phpMyAdmin.phar.tar.php'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">copy</span><span style="color: #007700">(</span><span style="color: #DD0000">'phpMyAdmin-2.11.3-english.tar.gz'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'phpMyAdmin.phar.tar.php'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$a&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">'phpMyAdmin.phar.tar.php'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$a</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">startBuffering</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">$a</span><span style="color: #007700">[</span><span style="color: #DD0000">"phpMyAdmin-2.11.3-english/config.inc.php"</span><span style="color: #007700">]&nbsp;=&nbsp;</span><span style="color: #DD0000">'&lt;?php<br />/*&nbsp;Servers&nbsp;configuration&nbsp;*/<br />$i&nbsp;=&nbsp;0;<br /><br />/*&nbsp;Server&nbsp;localhost&nbsp;(config:root)&nbsp;[1]&nbsp;*/<br />$i++;<br />$cfg[\'Servers\'][$i][\'host\']&nbsp;=&nbsp;\'localhost\';<br />$cfg[\'Servers\'][$i][\'extension\']&nbsp;=&nbsp;\'mysqli\';<br />$cfg[\'Servers\'][$i][\'connect_type\']&nbsp;=&nbsp;\'tcp\';<br />$cfg[\'Servers\'][$i][\'compress\']&nbsp;=&nbsp;false;<br />$cfg[\'Servers\'][$i][\'auth_type\']&nbsp;=&nbsp;\'config\';<br />$cfg[\'Servers\'][$i][\'user\']&nbsp;=&nbsp;\'root\';<br />$cfg[\'Servers\'][$i][\'password\']&nbsp;=&nbsp;\'\';<br /><br /><br />/*&nbsp;End&nbsp;of&nbsp;servers&nbsp;configuration&nbsp;*/<br />if&nbsp;(strpos(PHP_OS,&nbsp;\'WIN\')&nbsp;!==&nbsp;false)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;$cfg[\'UploadDir\']&nbsp;=&nbsp;getcwd();<br />}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;$cfg[\'UploadDir\']&nbsp;=&nbsp;\'/tmp/pharphpmyadmin\';<br />&nbsp;&nbsp;&nbsp;&nbsp;@mkdir(\'/tmp/pharphpmyadmin\');<br />&nbsp;&nbsp;&nbsp;&nbsp;@chmod(\'/tmp/pharphpmyadmin\',&nbsp;0777);<br />}'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$a</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::interceptFileFuncs();<br />Phar::webPhar("phpMyAdmin.phar",&nbsp;"phpMyAdmin-2.11.3-english/index.php");<br />echo&nbsp;"phpMyAdmin&nbsp;is&nbsp;intended&nbsp;to&nbsp;be&nbsp;executed&nbsp;from&nbsp;a&nbsp;web&nbsp;browser\n";<br />exit&nbsp;-1;<br />__HALT_COMPILER();<br />'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$a</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">stopBuffering</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
 </p>
</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="phar.using.html">Using Phar Archives</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="phar.using.stream.html">Using Phar Archives: the phar stream wrapper</a></div>
 <div class="up"><a href="phar.using.html">Using Phar Archives</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>