Skip to content

A powerful PHP-CLI tool to manage phar (PHP-Archive) files

License

Notifications You must be signed in to change notification settings

EvolSoft/PharTools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

start2

PharTools

PharTools is a powerful PHP-CLI tool to manage phar (PHP-Archive) files. It allows to create, extract, edit and view phar archives. It also includes a simple API to implement PharTools features on your own scripts.

Features:

  • Create phar archives
  • Extract phar archives
  • Add, rename, delete, list files inside phar archives
  • Get informations about phar archives (such as filesize, metadata, stub, etc...)
  • Converts zip or tar archives to phar archives
  • Converts phar archives to zip or tar archives
  • Supports GZip and BZip2 compression types (BZip2 needs the php_bz2 extension which is already included on the Windows installer)

Don't run this script directly. Run it from a cmd.exe or from a Linux Terminal instance instead

If you install PharTools on Windows directories (like Program Files, Program Files (x86), ...) you may need to run cmd.exe as Administrator

To create phar files you need to set php.readonly to 0 in php.ini configuration

Documentation

Manual configuration

Windows

To configure PharTools on Windows you need only to edit %PHP_PATH% in phartools.cmd file by setting the right php executable path.

Linux

On Linux, PharTools usually doesn't require to be configured but if you have some problems, edit phartools.sh file.

Commands

If you are running PharTools on Windows you can simply run it calling phartools.cmd on command shell. On Linux you have to run phartools using ./phartools.sh instead.

Example

phartools -h (Windows)

./phartools.sh -h (Linux)

Add a file to a phar archive:

phartools -a <phar_archive> <file>

file can be either a file or a non-empty directory.

Create a phar archive:

phartools -c <destination_phar> <source_dir | source_file> [options]

options switches:

-zgzip|-zbzip2 Compress the phar file using gzip or bzip2 compression
-m<metadata> Add metadata to the phar file (metadata format must be like 'key=>value,key2=>value2')
-s<stub> Set stub string for the phar
-r<regex> Include only files matching the regular expression

Delete a file from a phar archive:

phartools -d <phar_archive> <file>

file can be either a file or a directory.

Extract a phar archive:

phartools -e <phar_archive> [extract_path]

If extract_path is not specified, the archive will be extracted in the current directory

Get informations of a phar archive:

phartools -i <phar_archive>

List files inside a phar archive:

phartools -l <phar_archive>

Rename a file into a phar archive:

phartools -r <phar_archive> <oldname> <newname>

Convert zip or tar archive to a phar archive:

phartools -a2p <archive> [compression]

Currently supported compression types are gzip and bzip2

Convert a phar archive to a zip or tar archive:

phartools -p2a <phar_archive> [options]

options switches:

-zgzip|-zbzip2 Set output compression type
-ozip|-otar Set output archive type

Available PharTools Downloads

All platforms:

PharTools_v2.0.zip (Script only)

Windows:

PharTools_v2.0_win_installer (Preconfigured Script + Precompiled PHP binaries)
PharTools_v2.0_win_portable (Preconfigured Script + Precompiled PHP binaries, No Installer)

Please note that precompiled PHP binaries provided in the Portable and Installer versions are provided with minimal extensions and configuration

Screenshots

Windows

1. Open Windows Command Shell
1
2. Go to PharTools directory
2
3. Run PharTools
3

Linux

1. Open Linux Terminal
1 2
2. Go to PharTools directory
2 2
3. Run PharTools
3 2

Donate

If you want you can support this project with a small donation by clicking 💵 here. Your generosity will help us paying web hosting, domains, buying programs (such as IDEs, debuggers, etc...) and new hardware to improve software development. Thank you 😄

Contributing

If you want to contribute to this project please follow the Contribution Guidelines

About

A powerful PHP-CLI tool to manage phar (PHP-Archive) files

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published