|
2 | 2 |
|
3 | 3 | PHP Code compiler - Phar executable compiling utility |
4 | 4 |
|
5 | | -## Requirements |
6 | | - |
7 | | -- `php` or `paw` 7.1+ |
8 | | -- `phar.readonly` php config directive must be set to `Off` |
9 | | - |
10 | | -## Install |
11 | | - |
12 | | -_Get the latest release from Github_ |
13 | | - |
14 | | -> :bulb: `${BINDIR}` may be /usr/bin, /usr/local/bin or $HOME/bin |
15 | | -
|
16 | | -```bash |
17 | | -curl -Lo ${BINDIR}/phpcc https://github.com/yannoff/phpcc/releases/latest/download/phpcc |
18 | | -``` |
19 | | -_Add execution permissions to the binary_ |
20 | | - |
21 | | -```bash |
22 | | -chmod +x ${BINDIR}/phpcc |
23 | | -``` |
| 5 | +## Help Contents |
| 6 | + |
| 7 | +- [Usage](#usage) |
| 8 | + - [Synopsis](#synopsis) |
| 9 | + - [Options/Arguments](#optionsarguments) |
| 10 | + - [Examples](#examples) |
| 11 | + - [A concrete use-case: the `phpcc` self-compiling command](#a-concrete-use-case-the-phpcc-self-compiling-command) |
| 12 | + - [Example 1: PHP sources located in several directories](#example-1-php-sources-located-in-several-directories) |
| 13 | + - [Example 2: Multiple extensions in the same directory](#example-2-multiple-extensions-in-the-same-directory) |
| 14 | + - [Example 3: Standalone php script](#example-3-standalone-php-script) |
| 15 | + - [Example 4: Add sparse single PHP files](#example-4-add-sparse-single-php-files) |
| 16 | + - [Example 5: Adding metadata to the archive](#example-5-adding-metadata-to-the-archive) |
| 17 | +- [Install](#install) |
| 18 | + - [Requirements](#requirements) |
| 19 | + - [Quick install](#quick-install) |
| 20 | + - [Nightly versions](#nightly-versions) |
| 21 | +- [License](#license) |
24 | 22 |
|
25 | 23 | ## Usage |
26 | 24 |
|
@@ -62,7 +60,101 @@ Name / Shorthand | Type | Description |
62 | 60 | ```bash |
63 | 61 | phpcc -d src:php -d vendor:php -e bin/compile.php -o bin/phpcc -b .banner |
64 | 62 | ``` |
65 | | -_More use cases can be found in the [examples](doc/examples.md) documentation._ |
| 63 | + |
| 64 | +#### Example 1: PHP sources located in several directories |
| 65 | + |
| 66 | +- Add all `*.php` files from `src/` and `vendor/` dirs |
| 67 | +- Define `main.php` as the stub main entrypoint script |
| 68 | +- Save compiled phar executable to `bin/foobar` |
| 69 | + |
| 70 | +```bash |
| 71 | +phpcc -d src:php -d vendor:php -e main.php -o bin/foobar |
| 72 | +``` |
| 73 | +#### Example 2: Multiple extensions in the same directory |
| 74 | + |
| 75 | +- Add all `*.php` and `*.phtml` files from `src/` dir |
| 76 | +- Define `main.php` as the stub main entrypoint script |
| 77 | +- Save compiled phar executable to `bin/foobar` |
| 78 | + |
| 79 | +```bash |
| 80 | +phpcc -d src:php -d src:phtml -e main.php -o bin/foobar |
| 81 | +``` |
| 82 | + |
| 83 | +#### Example 3: Standalone php script |
| 84 | + |
| 85 | +- Define `app.php` as the stub main entrypoint script |
| 86 | +- Save compiled phar executable to `foobar.phar` |
| 87 | +- Use `LICENSE` file contents as legal notice banner |
| 88 | + |
| 89 | +```bash |
| 90 | +phpcc -e app.php -o foobar.phar -b LICENSE |
| 91 | +``` |
| 92 | + |
| 93 | +#### Example 4: Add sparse single PHP files |
| 94 | + |
| 95 | +- Define `app.php` as the stub main entrypoint script |
| 96 | +- Save compiled phar executable to `foobar.phar` |
| 97 | +- Add `foo.php` and `bar.php` files to the archive |
| 98 | + |
| 99 | +```bash |
| 100 | +phpcc -e app.php -o foobar.phar -f foo.php -f bar.php |
| 101 | +``` |
| 102 | + |
| 103 | +#### Example 5: Adding metadata to the archive |
| 104 | + |
| 105 | +- Define `app.php` as the stub main entrypoint script |
| 106 | +- Save compiled phar executable to `bin/acme` |
| 107 | +- Add the `license` & `author` metadata to the archive |
| 108 | + |
| 109 | +```bash |
| 110 | +phpcc -e app.php -o bin/acme -m license:MIT -m author:yannoff |
| 111 | +``` |
| 112 | + |
| 113 | +## Install |
| 114 | + |
| 115 | +### Requirements |
| 116 | + |
| 117 | +- `php` or `paw` 7.1+ |
| 118 | +- `phar.readonly` php config directive must be set to `Off` |
| 119 | + |
| 120 | +### Quick install |
| 121 | + |
| 122 | +_Get the latest release from Github_ |
| 123 | + |
| 124 | +> :bulb: `${BINDIR}` may be /usr/bin, /usr/local/bin or $HOME/bin |
| 125 | +
|
| 126 | +```bash |
| 127 | +curl -Lo ${BINDIR}/phpcc https://github.com/yannoff/phpcc/releases/latest/download/phpcc |
| 128 | +``` |
| 129 | +_Add execution permissions to the binary_ |
| 130 | + |
| 131 | +```bash |
| 132 | +chmod +x ${BINDIR}/phpcc |
| 133 | +``` |
| 134 | + |
| 135 | +### Nightly versions |
| 136 | + |
| 137 | +Want to test the edge version ? |
| 138 | + |
| 139 | +_Clone a local copy of the repository_ |
| 140 | + |
| 141 | +```bash |
| 142 | +git clone https://github.com/yannoff/phpcc.git |
| 143 | +``` |
| 144 | + |
| 145 | +_Symlink the binary_ |
| 146 | + |
| 147 | +```bash |
| 148 | +cd ${BINDIR} |
| 149 | +ln -s /path/to/working/copy/bin/phpcc |
| 150 | +``` |
| 151 | + |
| 152 | +_Stay up-to-date_ |
| 153 | + |
| 154 | +```bash |
| 155 | +cd /path/to/working/copy |
| 156 | +git pull --rebase |
| 157 | +``` |
66 | 158 |
|
67 | 159 | ## License |
68 | 160 |
|
|
0 commit comments