SPL-StandardPHPLibrary
phar_from_dir.php
Go to the documentation of this file.
1 <?php
2 
16 if ($argc < 3)
17 {
18  echo <<<EOF
19 php phar_from_dir.php archive directory [regex]
20 
21 Packs files in a given directory into a phar archive.
22 
23 archive name of the archive to create
24 directory input directory to pack
25 regex optional expression to match files in directory
26 
27 EOF;
28  exit(1);
29 }
30 
31 $phar = new Phar($argv[1], 0, 'newphar');
32 
35 if ($argc > 3)
36 {
37  $dir = new RegexIterator($dir, '/'.$argv[3].'/');
38 }
39 
40 $phar->begin();
41 
42 foreach($dir as $file)
43 {
44  echo "$file\n";
45  copy($file, "phar://newphar/$file");
46 }
47 
48 $phar->commit();
49 
50 ?>
Iterates through recursive iterators.
if($argc< 3) $phar
$dir
Regular expression filter for iterators.
recursive directory iterator
Definition: spl.php:1034