PHP_Archive
[ class tree: PHP_Archive ] [ index: PHP_Archive ] [ all elements ]

Class: PHP_Archive_Creator

Source Location: /PHP_Archive-0.13.0/Archive/Creator.php

Class Overview


PHP_Archive Class creator (implements .phar)


Author(s):

Version:

  • $Id$

Copyright:

  • Copyright ? David Shafik and Synaptic Media 2004. All rights reserved.

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 31]
PHP_Archive Class creator (implements .phar)

PHAR files a singular archive from which an entire application can run. To use it, simply package it using {@see PHP_Archive_Creator} and use phar:// URIs to your includes. i.e. require_once 'phar://config.php' will include config.php from the root of the PHAR file.

Gz code borrowed from the excellent File_Archive package by Vincent Lascaux.



[ Top ]


Class Variables

$alias =

[line 51]

  • Var: The phar alias
  • Access: protected

Type:   string


[ Top ]

$archive_name =

[line 36]

  • Var: The Archive Filename
  • Access: protected

Type:   string


[ Top ]

$collapse =  false

[line 67]

  • Var: Whether or not to collapse (remove whitespace/comments)
  • Access: protected

Type:   boolean


[ Top ]

$compress =  false

[line 56]

  • Var: Whether or not the archive should be compressed
  • Access: protected

Type:   boolean


[ Top ]

$flags =  0

[line 63]

Phar bitmapped flags
  • Access: protected

Type:   int


[ Top ]

$initFile =  false

[line 82]

  • Access: protected

Type:   mixed


[ Top ]

$manifest = array()

[line 79]

Used to construct the internal manifest, or listing of files/directories
  • Access: protected

Type:   array


[ Top ]

$metadata =  null

[line 88]

Used to save Phar-specific metadata
  • Access: protected

Type:   mixed


[ Top ]

$modified =  false

[line 72]

  • Var: Whether or not a file has been added to the archive
  • Access: protected

Type:   boolean


[ Top ]

$relyOnPhar =  false

[line 81]

  • Access: protected

Type:   mixed


[ Top ]

$save_path =

[line 46]

  • Var: Where the TAR archive will be saved
  • Access: protected

Type:   string


[ Top ]

$sig =

[line 95]

Signature type, either PHP_Archive::SHA1 or PHP_Archive::MD5
  • Access: protected

Type:   int


[ Top ]

$temp_path =

[line 41]

  • Var: The temporary path to the TAR archive
  • Access: protected

Type:   string


[ Top ]



Method Detail

__construct (Constructor)   [line 140]

PHP_Archive_Creator __construct( [string|false $init_file = 'index.php'], string $alias, [string|false $compress = false], [bool $relyOnPhar = false], [bool $collapse = false])

PHP_Archive Constructor
  • Access: public

Parameters:

string|false   $init_file   —  Init file (file called by default upon PHAR execution). if false, none will be called, and execution will return. use this option for libraries
string   $alias   —  alias name like "go-pear.phar" to be used for opening files from this phar
string|false   $compress   —  Whether to compress the files or not (will cause slowdown!) use 'gz' for zlib compression, 'bz2' for bzip2 compression
bool   $relyOnPhar   —  if true, then a slim, phar extension-dependent .phar will be created
bool   $collapse   —  Remove whitespace and comments from PHP_Archive class

[ Top ]

addArray   [line 793]

unknown addArray( unknown_type $files, [bool $magicrequire = false])

add an array of files to the archive
  • Access: public

Parameters:

unknown_type   $files   — 
bool   $magicrequire   —  determines whether to attempt to replace all calls to require or include with internal phar includes

[ Top ]

addDir   [line 744]

boolean addDir( string $dir, [array $ignore = array()], [array $include = array()], [bool $magicrequire = false], [string $toplevel = null])

Add a directory to the archive
  • Access: public

Parameters:

string   $dir   —  The directory path to add
array   $ignore   —  files to ignore
array   $include   —  files to include (all others ignored)
bool   $magicrequire   —  If set, then "require_once '" will be replaced with "require_once 'phar://$magicrequire/" [deprecated]
string   $toplevel   —  Directory to consider as the top-level directory

[ Top ]

addFile   [line 257]

boolean addFile( string $file, string $save_path, [false $magicrequire = false], [mixed $metadata = null])

Add a file to the PHP Archive
  • Access: public

Parameters:

string   $file   —  Path of the File to add
string   $save_path   —  The save location of the file in the archive
false   $magicrequire   —  unused, set this to false
mixed   $metadata   —  Any file-specific metadata to save

[ Top ]

addMagicRequireCallback   [line 240]

void addMagicRequireCallback( callback $callback)

Specify a custom "magic require" callback for processing file contents.

This will be called regardless of the magicrequire parameter's value for addString() or addFile()

  • Access: public

Parameters:

callback   $callback   — 

[ Top ]

addString   [line 378]

boolean addString( string $file_contents, string $save_path, [ $magicrequire = false], [ $metadata = null])

Add a string to the PHP Archive as a file
  • Access: public

Parameters:

string   $file_contents   —  Contents of the File to add
string   $save_path   —  The save location of the file in the archive
   $magicrequire   — 
   $metadata   — 

[ Top ]

clearMagicRequire   [line 431]

void clearMagicRequire( )

  • Access: public

[ Top ]

dirList   [line 682]

array dirList( string $directory, [ $toplevel = null])

Retrieve a listing of every file in $directory and all subdirectories.

The return format is an array of full paths to files

  • Return: list of files in a directory
  • Access: public

Parameters:

string   $directory   —  full path to the directory you want the list of
   $toplevel   — 

[ Top ]

limitedSmartMagicRequire   [line 457]

void limitedSmartMagicRequire( string $contents, string $path)

prepends "phar://alias" only to include/require that use quotes
  • Access: public

Parameters:

string   $contents   —  file contents
string   $path   —  internal path of the file

[ Top ]

processFile   [line 108]

void processFile( string $path)

  • Access: public

Parameters:

string   $path   — 

[ Top ]

savePhar   [line 810]

bool savePhar( string $file_path)

Construct the .phar and save it
  • Return: success of operation
  • Access: public

Parameters:

string   $file_path   — 

[ Top ]

serializeManifest   [line 883]

string serializeManifest( array $manifest)

serialize the manifest in a C-friendly way
  • Access: public

Parameters:

array   $manifest   —  An array like so:
  1.    $manifest[= array(
  2.       $savepath,
  3.       $size// original size = 0
  4.       time()// save time = 1
  5.       $offset// offset from start of files = 2
  6.       $info['actualsize'])// actual size in the .phar = 3

[ Top ]

setPharMetadata   [line 209]

void setPharMetadata( mixed $metadata)

Set meta-data for entire Phar archive
  • Access: public

Parameters:

mixed   $metadata   — 

[ Top ]

simpleMagicRequire   [line 442]

void simpleMagicRequire( string $contents, string $path)

prepends all include/require calls with "phar://alias"
  • Access: public

Parameters:

string   $contents   —  file contents
string   $path   —  internal path of the file

[ Top ]

smartMagicRequire   [line 471]

void smartMagicRequire( string $contents, string $path)

The basic magicrequire callback (implements old-fashioned magicrequire)
  • Access: public

Parameters:

string   $contents   —  file contents
string   $path   —  internal path of the file

[ Top ]

tokenMagicRequire   [line 479]

void tokenMagicRequire( $contents, $path)

  • Access: public

Parameters:

   $contents   — 
   $path   — 

[ Top ]

useDefaultFrontController   [line 280]

void useDefaultFrontController( [string $indexfile = false], [array $defaultmimes = false], [array $defaultphp = false], [array $defaultphps = false], [array $deny = false])

For web-based applications, construct a default front controller that will direct to the correct file within the phar.
  • Access: public

Parameters:

string   $indexfile   —  relative path to startup index file (defaults to the same file as is used for CLI startup)
array   $defaultmimes   —  list of MIME types to use, associative array of extension => mime type. default is from PHP_Archive::$defaultmimes
array   $defaultphp   —  list of file extensions that should be parsed as PHP. default is from PHP_Archive::$defaultphp
array   $defaultphps   —  list of file extensions that should be parsed as PHP source. default is from PHP_Archive::$defaultphps
array   $deny   —  list of files that should be hidden (return a 404 response) Each file should be a valid pcre regular expression like '/.+\.inc$/', which will deny all .inc files from being served. The default is from PHP_Archive::$deny

[ Top ]

useMD5Signature   [line 226]

void useMD5Signature( )

Append a signature to this phar when it is created
  • Access: public

[ Top ]

useSHA1Signature   [line 217]

void useSHA1Signature( )

Append a signature to this phar when it is created
  • Access: public

[ Top ]


Documentation generated on Tue, 19 Nov 2019 16:23:07 -0500 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.