Sophie

Sophie

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

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>Construct a phar archive from the files within a directory.</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="phar.apiversion.html">Phar::apiVersion</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="phar.buildfromiterator.html">Phar::buildFromIterator</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.buildfromdirectory" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Phar::buildFromDirectory</h1>
  <p class="verinfo">(PHP &gt;= 5.3.0, PECL phar &gt;= 2.0.0)</p><p class="refpurpose"><span class="refname">Phar::buildFromDirectory</span> &mdash; <span class="dc-title">Construct a phar archive from the files within a directory.</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-phar.buildfromdirectory-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">array</span> <span class="methodname"><strong>Phar::buildFromDirectory</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$base_dir</code></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$regex</code></span>
  ] )</div>

  <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para">This
method requires the <var class="filename">php.ini</var> setting <em>phar.readonly</em> to be
set to <em>0</em> in order to work for <a href="class.phar.html" class="classname">Phar</a>
objects.  Otherwise, a <a href="class.pharexception.html" class="classname">PharException</a> will be thrown.</p></p></blockquote>
  <p class="para">
   Populate a phar archive from directory contents.  The optional second
   parameter is a regular expression (pcre) that is used to exclude files.
   Any filename that matches the regular expression will be included, all others will be
   excluded.  For more fine-grained control, use  <span class="function"><a href="phar.buildfromiterator.html" class="function">Phar::buildFromIterator()</a></span>.
  </p>
 </div>


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

    <dt>

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

      <p class="para">
       The full or relative path to the directory that contains all files
       to add to the archive.
      </p>
     </dd>

    </dt>

    <dt>

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

      <p class="para">
       An optional pcre regular expression that is used to filter the
       list of files.  Only file paths matching the regular expression
       will be included in the archive.
      </p>
     </dd>

    </dt>

   </dl>

  </p>

 </div>

 <div class="refsect1 returnvalues" id="refsect1-phar.buildfromdirectory-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
    <span class="function"><strong>Phar::buildFromDirectory()</strong></span> returns an associative array
   mapping internal path of file to the full path of the file on the
   filesystem.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-phar.buildfromdirectory-errors">
  <h3 class="title">Errors/Exceptions</h3>
  <p class="para">
   This method throws <a href="class.badmethodcallexception.html" class="classname">BadMethodCallException</a> when unable
   to instantiate the internal directory iterators,
   or a <a href="class.pharexception.html" class="classname">PharException</a> if there were errors
   saving the phar archive.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-phar.buildfromdirectory-examples">
  <h3 class="title">Examples</h3>
  <div class="example" id="example-660">
    <p><strong>Example #1 A  <span class="function"><strong>Phar::buildFromDirectory()</strong></span> example</strong></p>
  <div class="example-contents"><p>
   
  </p></div>
  <div class="example-contents"><p>
   <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;create&nbsp;with&nbsp;alias&nbsp;"project.phar"<br /></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">'project.phar'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'project.phar'</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">//&nbsp;add&nbsp;all&nbsp;files&nbsp;in&nbsp;the&nbsp;project<br /></span><span style="color: #0000BB">$phar</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">buildFromDirectory</span><span style="color: #007700">(</span><span style="color: #0000BB">dirname</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">'/project'</span><span style="color: #007700">);<br /></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: #0000BB">$phar</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">createDefaultStub</span><span style="color: #007700">(</span><span style="color: #DD0000">'cli/index.php'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'www/index.php'</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">$phar2&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">'project2.phar'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">0</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'project2.phar'</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">//&nbsp;add&nbsp;all&nbsp;files&nbsp;in&nbsp;the&nbsp;project,&nbsp;only&nbsp;include&nbsp;php&nbsp;files<br /></span><span style="color: #0000BB">$phar2</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">buildFromDirectory</span><span style="color: #007700">(</span><span style="color: #0000BB">dirname</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">'/project'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'/\.php$/'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$phar2</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setStub</span><span style="color: #007700">(</span><span style="color: #0000BB">$phar</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">createDefaultStub</span><span style="color: #007700">(</span><span style="color: #DD0000">'cli/index.php'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'www/index.php'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

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


 <div class="refsect1 seealso" id="refsect1-phar.buildfromdirectory-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"> <span class="function"><a href="phar.buildfromiterator.html" class="function" rel="rdfs-seeAlso">Phar::buildFromIterator()</a> - Construct a phar archive from an iterator.</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.apiversion.html">Phar::apiVersion</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="phar.buildfromiterator.html">Phar::buildFromIterator</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>