Php compaction tool, that allow you to make a .phar of your php project and Library.
Go to file Use this template
2022-08-08 19:31:21 +02:00
src initial commit 2022-08-08 19:30:07 +02:00
.gitignore initial commit 2022-08-08 19:30:07 +02:00
LICENSE initial commit 2022-08-08 19:30:07 +02:00
phar-creator.php initial commit 2022-08-08 19:30:07 +02:00
README.md update readme 2022-08-08 19:31:21 +02:00
win-build.cmd initial commit 2022-08-08 19:30:07 +02:00

phar-creator

Donate Website

Description

Phar-Creator is a PHP compaction tool that allows you to compress your project, library, etc. into a .phar archive, so that you have a single file containing them all. You can freely add an entry point in case your program is made to be executed directly by client, a web entry point, or meta data and more. The compaction tool will also provide you with a Sha256 fingerprint of the resulting .phar.

Use

You will find below the two modes of use of the tool, the first by using the provided windows executable win-build.cmd or the CLI (terminal). The second one by accessing directly the script via internet (WEB).

For these two modes of use you will have to configure the script in the section CONSTANTS to config. This repository is already a complete example of phar-creator use. Our example is called hello-world it has been made to be as understandable as possible I invite you to browse it to discover the structure (people used to it can abstain).

CLI packaging

Requirements

  • PHP version >= 7.4 ;
  • PHP must be CLI ready (win: add to environement variable, linux: installed) ;

Examples by method

  1. Run the script directly into your terminal php -dphar.readonly=0 phar-creator.php.
  2. Run the win-build.cmd script.

WEB packaging

Requirements

  • PHP version >= 7.4 ;
  • The web server must have read and write permissions or run as administrator ;
  • In the php.ini, phar.readonly must be disabled, so set to false ;

Example web

  • Simply navigate to the access url of the script http://your-website.domain/phar-creator.php.

Project structure (example)

*
│   phar-creator.php        ==> The main tool to place in project's root directory.
│   LICENSE
│   README.md
│   win-build.cmd           ==> The windows script to start the tool.
├───build                   ==> The build directory.
│       hello-world.phar
└───src                     ==> The source code directory.
    │   main.php            ==> The hello-world (example) entrypoint.
    ├───factory
    │       personFactory.php
    ├───model
    │       Person.php
    └───utils
            func.php