Giter Site home page Giter Site logo

evolsoft / phartools Goto Github PK

View Code? Open in Web Editor NEW
29.0 7.0 0.0 32 KB

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

Home Page: https://www.evolsoft.tk/phartools/

License: MIT License

PHP 97.52% Shell 1.85% Batchfile 0.63%
php-cli php phar-files archiving packaging

phartools's Introduction

start2

PharTools

PharTools is a powerful PHP command-line 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)

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

Requirements

  • At least PHP 5.3.0
  • Optional: php_bz2 extension (to implement BZip2 compression support)

Installation

You can download the PharTools packages at this page. You will find three download options:

All platforms:

PharTools_vx.x.zip (script only)

Windows:

PharTools_vx.x_win_installer.exe (preconfigured script + precompiled PHP binaries)
PharTools_vx.x_win_portable.zip (preconfigured script + precompiled PHP binaries, no installer)

Please note that precompiled PHP binaries included in the portable and installer pacakages are provided with minimal extensions and configuration

Windows

PharTools installation on Windows is very simple. You have three choices:

  • download the installer
  • download the Windows portable package
  • download the all-platforms zip package and configure PharTools manually

If choose the third option, you must simply edit the %PHP_PATH% variable in phartools.cmd file by setting a valid PHP executables path.

NOTE: if you install PharTools on Windows directories (like Program Files, Program Files (x86), ...) you may need administrator privileges in order to run the script correctly.

Linux

To install PharTools on Linux, download the all-platforms zip package. Then run:

$ ./phartools.sh

It should automatically install the PHP package (if missing) in order to run PharTools correctly or run PharTools directly. If you have problems while installing the PHP package, try to install it manually from your Linux distro package manager (i.e. apt-get).

macOS

You can run PharTools also on macOS. PharTools installation on macOS is very easy: you just need to download the all-platforms zip package. No PHP installation is required because PHP is already bundled with macOS since Mac OS X 10.0.0.

Usage

$ phartools -h

Usage:
  -a <phar_archive> <files> Add files to a phar archive
  -c <phar_archive> <files> [options] Create a phar archive
  -d <phar_archive> <file> Delete a file from a phar archive
  -e <phar_archive> [extract_path] Extract a phar archive
  -h Show this help screen
  -i <phar_archive> Show info about a phar archive
  -l <phar_archive> List the content of a phar archive
  -r <phar_archive> <oldname> <newname> Rename a file inside a phar archive
  -a2p <archive> [compression] Convert a zip or tar archive to a phar archive
  -p2a <phar_archive> [options] Convert a phar archive to a zip or tar archive

-a (add) command

Adds files to a phar archive.

$ phartools -a <phar_archive> <files>

Parameters:

<phar_archive> is the destination phar archive
<files> are the files you want to add (wildcards are allowed)

-c (create) command

Creates a phar archive.

$ phartools -c <phar_archive> <files> [options]

Parameters:

<phar_archive> is the name of the resulting phar archive
<files> are the source files to add inside the phar archive (wildcards are allowed)
[options] are optional 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

-d (delete) command

Deletes a file from a phar archive.

$ phartools -d <phar_archive> <file>

Parameters:

<phar_archive> is the destination phar archive
<file> is the file or the directory you want to delete

-e (extract) command

Extracts a phar archive.

$ phartools -e <phar_archive> [extract_path]

Parameters:

<phar_archive> is the destination phar archive
[extract_path] is an optional parameter specifying the path on which the phar archive contents will be extracted

-i (show archive info) command

Shows informations about a phar archive.

$ phartools -i <phar_archive>

Parameters:

<phar_archive> is the destination phar archive

-l (list archive content) command

Lists the content of a phar archive.

$ phartools -l <phar_archive>

Parameters:

<phar_archive> is the destination phar archive

-r (rename) command

Renames a file inside a phar archive.

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

Parameters:

<phar_archive> is the destination phar archive
<oldname> is the name of the file to rename
<newfile> is the new filename

-a2p (archive to phar archive) command

Converts a zip or tar archive to a phar archive.

$ phartools -a2p <archive> [compression]

Parameters:

<archive> is the zip or tar archive to convert
[compression] is an optional parameter specifying compression:
	gzip Compress the phar archive using gzip compression
	bzip2 Compress the phar archive using bzip2 compression

-p2a (phar archive to archive) command

Converts a phar archive to a zip or tar archive.

$ phartools -p2a <phar_archive> [options]

Parameters:

<phar_archive> is the destination phar archive
[options] are optional switches:
	-zgzip|-zbzip2 Compress the resulting archive file using gzip or bzip2 compression (zip archives do not support compression)
	-ozip|-otar Set the output archive format (zip or tar archive)

API

PharTools provides also an API to simplify the usage of phar archives:

include "path/to/phartools.php";

PharTools::<api_function>();

Screenshots

Windows

PharTools command-line interface
1
PharTools file list example
2

Linux

PharTools command-line interface
3
PharTools file list example
4

macOS

PharTools command-line interface
5
PharTools file list example
6

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.

phartools's People

Contributors

flavius12 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

phartools's Issues

Does not generate the source folder

(Windows)

Does not generate the source folder ๐ŸŒš

The console say:

Extracting...
Extracted in C:\Program Files\PharTools!

But the source folder is not in that directory

Serious issue

I don't know how to properly say 'thank you' for this great utility.

So I've resorted to this.

Parse error: syntax error, unexpected '[' on line 208

# ./phartools.sh

**Parse error: syntax error, unexpected '[', expecting ',' or ';' in phartools.php on line 208**

# php -v
PHP 5.3.3 (cli) (built: Mar 22 2017 12:27:09)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with the ionCube PHP Loader (enabled) + Intrusion Protection from ioncube24.com (unconfigured) v5.1.2, Copyright (c) 2002-2016, by ionCube Ltd.

# cat /etc/redhat-release
CentOS release 6.9 (Final)

The offending lines:

                    echo "Signature: " . $phar->getSignature()["hash"] . "\n";
                    echo "Signature type: " . $phar->getSignature()["hash_type"] . "\n";

???

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.