Sophie

Sophie

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

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>Convert a phar archive to a non-executable tar or zip file</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="phardata.construct.html">PharData::__construct</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="phardata.converttoexecutable.html">PharData::convertToExecutable</a></div>
 <div class="up"><a href="class.phardata.html">PharData</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="phardata.converttodata" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">PharData::convertToData</h1>
  <p class="verinfo">(PHP &gt;= 5.3.0, PECL phar &gt;= 2.0.0)</p><p class="refpurpose"><span class="refname">PharData::convertToData</span> &mdash; <span class="dc-title">Convert a phar archive to a non-executable tar or zip file</span></p>

 </div>


 <div class="refsect1 description" id="refsect1-phardata.converttodata-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type"><a href="class.phardata.html" class="type PharData">PharData</a></span> <span class="methodname"><strong>PharData::convertToData</strong></span>
    ([ <span class="methodparam"><span class="type">int</span> <code class="parameter">$format</code></span>
   [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$compression</code></span>
   [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$extension</code></span>
  ]]] )</div>


  <p class="para rdfs-comment">
   This method is used to convert a non-executable tar or zip archive to another
   non-executable format.
  </p>
  <p class="para">
   If no changes are specified, this method throws a <a href="class.badmethodcallexception.html" class="classname">BadMethodCallException</a>.
   This method should be used to convert a tar archive to zip format or vice-versa.  Although
   it is possible to simply change the compression of a tar archive using this method,
   it is better to use the  <span class="function"><a href="phardata.compress.html" class="function">PharData::compress()</a></span> method for logical
   consistency.
  </p>
  <p class="para">
   If successful, the method creates a new archive on disk and returns a <a href="class.phardata.html" class="classname">PharData</a>
   object.  The old archive is not removed from disk, and should be done manually after
   the process has finished.
  </p>
 </div>


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

    <dt>

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

      <p class="para">
       This should be one of <em>Phar::TAR</em>
       or <em>Phar::ZIP</em>.  If set to <strong><code>NULL</code></strong>, the existing file format
       will be preserved.
      </p>
     </dd>

    </dt>

    <dt>

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

      <p class="para">
       This should be one of <em>Phar::NONE</em> for no whole-archive
       compression, <em>Phar::GZ</em> for zlib-based compression, and
       <em>Phar::BZ2</em> for bzip-based compression.
      </p>
     </dd>

    </dt>

    <dt>

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

      <p class="para">
       This parameter is used to override the default file extension for a
       converted archive.  Note that <em>.phar</em> cannot be used
       anywhere in the filename for a non-executable tar or zip archive.
      </p>
      <p class="para">
       If converting to a tar-based phar archive, the
       default extensions are <em>.tar</em>, <em>.tar.gz</em>,
       and <em>.tar.bz2</em> depending on specified compression.
       For zip-based archives, the
       default extension is <em>.zip</em>.
      </p>
     </dd>

    </dt>

   </dl>

  </p>

 </div>

 <div class="refsect1 returnvalues" id="refsect1-phardata.converttodata-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   The method returns a <a href="class.phardata.html" class="classname">PharData</a> object on success and throws an
   exception on failure.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-phardata.converttodata-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 compress, an unknown compression method has been specified, the requested
   archive is buffering with  <span class="function"><a href="phar.startbuffering.html" class="function">Phar::startBuffering()</a></span> and
   has not concluded with  <span class="function"><a href="phar.stopbuffering.html" class="function">Phar::stopBuffering()</a></span>, and a
   <a href="class.pharexception.html" class="classname">PharException</a> if any problems are encountered
   during the phar creation process.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-phardata.converttodata-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-714">
    <p><strong>Example #1 A  <span class="function"><strong>PharData::convertToData()</strong></span> example</strong></p>
    <div class="example-contents"><p>
     Using PharData::convertToData():
    </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: #007700">try&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$tarphar&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">PharData</span><span style="color: #007700">(</span><span style="color: #DD0000">'myphar.tar'</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;note&nbsp;that&nbsp;myphar.tar&nbsp;is&nbsp;*not*&nbsp;unlinked<br />&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;convert&nbsp;it&nbsp;to&nbsp;the&nbsp;non-executable&nbsp;tar&nbsp;file&nbsp;format<br />&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;creates&nbsp;myphar.zip<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$zip&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$tarphar</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">convertToData</span><span style="color: #007700">(</span><span style="color: #0000BB">Phar</span><span style="color: #007700">::</span><span style="color: #0000BB">ZIP</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;create&nbsp;myphar.tbz<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$tgz&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$zip</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">convertToData</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">BZ2</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'.tbz'</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;creates&nbsp;myphar.phar.tgz<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$phar&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$tarphar</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">convertToData</span><span style="color: #007700">(</span><span style="color: #0000BB">Phar</span><span style="color: #007700">::</span><span style="color: #0000BB">PHAR</span><span style="color: #007700">);&nbsp;</span><span style="color: #FF8000">//&nbsp;throws&nbsp;exception<br /></span><span style="color: #007700">}&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;the&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-phardata.converttodata-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"> <span class="function"><a href="phar.converttoexecutable.html" class="function" rel="rdfs-seeAlso">Phar::convertToExecutable()</a> - Convert a phar archive to another executable phar archive file format</span></li>
    <li class="member"> <span class="function"><a href="phar.converttodata.html" class="function" rel="rdfs-seeAlso">Phar::convertToData()</a> - Convert a phar archive to a non-executable tar or zip file</span></li>
    <li class="member"> <span class="function"><a href="phardata.converttoexecutable.html" class="function" rel="rdfs-seeAlso">PharData::convertToExecutable()</a> - Convert a non-executable tar/zip archive to an executable phar archive</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="phardata.construct.html">PharData::__construct</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="phardata.converttoexecutable.html">PharData::convertToExecutable</a></div>
 <div class="up"><a href="class.phardata.html">PharData</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>