<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.phardata.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'de',
  ),
  'this' => 
  array (
    0 => 'phardata.buildfromdirectory.php',
    1 => 'PharData::buildFromDirectory',
    2 => 'Construct a tar/zip archive from the files within a directory',
  ),
  'up' => 
  array (
    0 => 'class.phardata.php',
    1 => 'PharData',
  ),
  'prev' => 
  array (
    0 => 'phardata.addfromstring.php',
    1 => 'PharData::addFromString',
  ),
  'next' => 
  array (
    0 => 'phardata.buildfromiterator.php',
    1 => 'PharData::buildFromIterator',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/phar/PharData/buildFromDirectory.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="phardata.buildfromdirectory" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">PharData::buildFromDirectory</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.3.0, PHP 7, PHP 8, PECL phar &gt;= 2.0.0)</p><p class="refpurpose"><span class="refname">PharData::buildFromDirectory</span> &mdash; <span class="dc-title">Construct a tar/zip archive from the files within a directory</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-phardata.buildfromdirectory-description">
  <h3 class="title">Beschreibung</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>PharData::buildFromDirectory</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$directory</code></span>, <span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$pattern</code><span class="initializer"> = &quot;&quot;</span></span>): <span class="type"><a href="language.types.array.php" class="type array">array</a></span></div>


  <p class="para rdfs-comment">
   Populate a tar/zip 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="phardata.buildfromiterator.php" class="function">PharData::buildFromIterator()</a></span>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-phardata.buildfromdirectory-parameters">
  <h3 class="title">Parameter-Liste</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">directory</code></dt>
     <dd>
      <p class="para">
       The full or relative path to the directory that contains all files
       to add to the archive.
      </p>
     </dd>
    
    
     <dt><code class="parameter">pattern</code></dt>
     <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>
    
   </dl>
  </p>

 </div>

 <div class="refsect1 returnvalues" id="refsect1-phardata.buildfromdirectory-returnvalues">
  <h3 class="title">Rückgabewerte</h3>
  <p class="para">
   <span class="function"><a href="phar.buildfromdirectory.php" class="function">Phar::buildFromDirectory()</a></span> returns an associative array
   mapping internal path of file to the full path of the file on the
   filesystem, Bei einem Fehler wird <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> zurückgegeben..
  </p>
 </div>


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


 <div class="refsect1 changelog" id="refsect1-phardata.buildfromdirectory-changelog">
  <h3 class="title">Changelog</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Version</th>
      <th>Beschreibung</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.1.0</td>
      <td>
       <span class="methodname"><strong>PharData::buildFromDirectory()</strong></span> no longer returns <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-phardata.buildfromdirectory-examples">
  <h3 class="title">Beispiele</h3>
  <div class="example" id="example-1">
    <p><strong>Beispiel #1 A <span class="function"><strong>PharData::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 />$phar </span><span style="color: #007700">= new </span><span style="color: #0000BB">PharData</span><span style="color: #007700">(</span><span style="color: #DD0000">'project.tar'</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">// add all files in the 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">) . </span><span style="color: #DD0000">'/project'</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">$phar2 </span><span style="color: #007700">= new </span><span style="color: #0000BB">PharData</span><span style="color: #007700">(</span><span style="color: #DD0000">'project2.zip'</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">// add all files in the project, only include php 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">) . </span><span style="color: #DD0000">'/project'</span><span style="color: #007700">, </span><span style="color: #DD0000">'/\.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-phardata.buildfromdirectory-seealso">
  <h3 class="title">Siehe auch</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="phar.buildfromdirectory.php" class="function" rel="rdfs-seeAlso">Phar::buildFromDirectory()</a> - Construct a phar archive from the files within a directory</span></li>
    <li><span class="function"><a href="phardata.buildfromiterator.php" class="function" rel="rdfs-seeAlso">PharData::buildFromIterator()</a> - Construct a tar or zip archive from an iterator</span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>