phar-creator/README.md

63 lines
2.6 KiB
Markdown
Raw Normal View History

2022-08-08 19:30:07 +02:00
# phar-creator
[![Donate][link-icon-coffee]][link-paypal-me] [![Website][link-icon-website]][link-website]
[link-icon-coffee]: https://img.shields.io/badge/%E2%98%95-Buy%20me%20a%20cup%20of%20coffee-991481.svg
[link-paypal-me]: https://www.paypal.me/EndMove/2.5eur
[link-icon-website]: https://img.shields.io/badge/%F0%9F%92%BB-My%20Web%20Site-0078D4.svg
[link-website]: https://www.endmove.eu/
## 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`.:k:=
## Project structure (example)
````txt
*
│ 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
````