File tree Expand file tree Collapse file tree 12 files changed +693
-0
lines changed
Expand file tree Collapse file tree 12 files changed +693
-0
lines changed Original file line number Diff line number Diff line change 1+ PHP Code Compiler - Phar executable compiling utility
2+
3+ Copyright (c) Yann Blacher (Yannoff) - MIT License
4+
5+ For the full copyright and license information, please see
6+ {@link https://github.com/yannoff/phpcc/blob/main/LICENSE}
Original file line number Diff line number Diff line change 1+ .git * export-exclude
2+ .banner export-exclude
3+ build.sh export-exclude
Original file line number Diff line number Diff line change 1+ /vendor /
Original file line number Diff line number Diff line change 1+ # yannoff/phpcc
2+
3+ PHP Code compiler - Phar executable compiling utility
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+ ```
24+
25+ ## Usage
26+
27+ ### Synopsis
28+
29+ ```
30+ phpcc --help
31+ phpcc --version
32+ phpcc -e <entrypoint> -o <output> [-d dir [-d dir ...]] [-b <banner>] [-l <license>]
33+ ```
34+
35+ ### Options/Arguments
36+
37+ > The output and entrypoint scripts are mandatory.
38+
39+ #### ` -e ` , ` --entrypoint `
40+
41+ ** MANDATORY** The main application entrypoint script.
42+
43+ #### ` -o ` , ` --output `
44+
45+ ** MANDATORY** The Phar archive output file.
46+
47+ #### ` -d ` , ` --dir `
48+
49+ Adds a PHP sources directory to the archive.
50+
51+ _ Multiple values allowed here_
52+
53+ > Each directory may be of the form:
54+ > - ` $dir ` => include all files in directory
55+ > - ` $dir:$extension ` => filter files on a specific extension
56+
57+ #### ` -b ` , ` --banner `
58+
59+ Filepath to the legal notice banner.
60+
61+ _ Will be included in the human-readable part of the stub._
62+
63+
64+ ### Examples
65+
66+ #### A concrete use-case: the ` phpcc ` self-compiling command
67+
68+ ``` bash
69+ phpcc -d src:php -d vendor:php -e bin/compile.php -o bin/phpcc -b .banner
70+ ```
71+ _ More use cases can be found in the [ examples] ( doc/examples.md ) documentation._
72+
73+ ## License
74+
75+ Licensed under the [ MIT License] ( LICENSE ) .
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /**
4+ * This file is part of the PHP Code Compiler project
5+ *
6+ * Copyright (c) Yannoff (https://github.com/yannoff)
7+ *
8+ * @project PHP Code Compiler (yannoff/phpcc)
9+ * @homepage https://github.com/yannoff/phpcc
10+ * @license https://github.com/yannoff/phpcc/blob/main/LICENSE
11+ *
12+ * For the full copyright and license information, please view
13+ * the LICENSE file that was distributed with this source code.
14+ */
15+
16+ error_reporting (E_ALL );
17+
18+ $ VERSION = '1.0.0 ' ;
19+
20+ /**
21+ * BEWARE:
22+ *
23+ * While the home-made Phar::addDirectory() method accepts both absolute or
24+ * relative-to-content-root paths here, this is not the case when directories
25+ * were added via the PHP builtin Phar::buildFromDirectory() method.
26+ *
27+ * The builtin Phar engine only recognize the latter, ie: require 'vendor/autoload.php';
28+ *
29+ * @see https://bugs.php.net/bug.php?id=63028
30+ */
31+ require 'vendor/autoload.php ' ;
32+
33+ use Yannoff \Component \Console \Application ;
34+ use Yannoff \PhpCodeCompiler \Command \Compile ;
35+
36+ $ app = new Application ('PHP Code Compiler ' , $ VERSION , (new Compile ()));
37+ $ app ->run ();
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ #
4+ # This file is part of the PHP Code Compiler project
5+ #
6+ # Copyright (c) Yannoff (https://github.com/yannoff)
7+ #
8+ # @project PHP Code Compiler (yannoff/phpcc)
9+ # @homepage https://github.com/yannoff/phpcc
10+ # @license https://github.com/yannoff/phpcc/blob/main/LICENSE
11+ #
12+ # For the full copyright and license information, please view
13+ # the LICENSE file that was distributed with this source code.
14+ #
15+
16+ version=$1
17+ phar=bin/phpcc
18+ main=bin/compile.php
19+
20+ if [ -z " $version " ]
21+ then
22+ echo " Error: missing version argument."
23+ exit 1
24+ fi
25+
26+ sed -i " s/\$ VERSION *=.*/\$ VERSION = '$version ';/" $main
27+
28+ php -dphar.readonly=0 bin/compile.php -d src:php -d vendor:php -e $main -o $phar -b .banner
Original file line number Diff line number Diff line change 1+ #
2+ # This file was generated automatically by Offenbach
3+ # @see https://github.com/yannoff/offenbach for details
4+ #
5+ _readme :
6+ - ' This file locks the dependencies of your project to a known state'
7+ - ' Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies'
8+ - ' This file is @generated automatically'
9+ content-hash : ad790642fb7ddbb04c314652a6ca6940
10+ packages :
11+ -
12+ name : yannoff/console
13+ version : 2.2.2
14+ source :
15+ type : git
16+ url : ' https://github.com/yannoff/console.git'
17+ reference : ac45b6a94cf5de7aeea63a1aa0bbb3eb1c4f4404
18+ dist :
19+ type : zip
20+ url : ' https://api.github.com/repos/yannoff/console/zipball/ac45b6a94cf5de7aeea63a1aa0bbb3eb1c4f4404'
21+ reference : ac45b6a94cf5de7aeea63a1aa0bbb3eb1c4f4404
22+ shasum : ' '
23+ require :
24+ php : ' >=5.5'
25+ type : library
26+ autoload :
27+ psr-4 :
28+ Yannoff\Component\Console\ : src/
29+ notification-url : ' https://packagist.org/downloads/'
30+ license :
31+ - MIT
32+ authors :
33+ -
34+ name : Yannoff
35+ homepage : ' https://github.com/yannoff'
36+ description : ' A simple, lightweight console implementation for command-line PHP applications.'
37+ homepage : ' https://github.com/yannoff/console'
38+ support :
39+ issues : ' https://github.com/yannoff/console/issues'
40+ source : ' https://github.com/yannoff/console/tree/2.2.2'
41+ time : ' 2023-10-30T15:31:09+00:00'
42+ packages-dev : []
43+ aliases : []
44+ minimum-stability : stable
45+ stability-flags : []
46+ prefer-stable : false
47+ prefer-lowest : false
48+ platform :
49+ php : ' >=7.1'
50+ platform-dev : []
51+ plugin-api-version : 2.2.0
Original file line number Diff line number Diff line change 1+ #
2+ # This file was generated automatically by Offenbach
3+ # @see https://github.com/yannoff/offenbach for details
4+ #
5+ name : yannoff/phpcc
6+ description : ' PHP Code Compiler - Phar executables compiling utility'
7+ type : project
8+ license : MIT
9+ config :
10+ sort-packages : true
11+ autoload :
12+ psr-4 :
13+ Yannoff\PhpCodeCompiler\ : src/
14+ require :
15+ php : ' >=7.1'
16+ yannoff/console : ^2.2
Original file line number Diff line number Diff line change 1+ # PHP Code Compiler Examples
2+
3+ ## Example 1: PHP sources located in several directories
4+
5+ - Add all ` *.php ` files from ` src/ ` and ` vendor/ ` dirs
6+ - Define ` main.php ` as the stub main entrypoint script
7+ - Save compiled phar executable to ` bin/foobar `
8+
9+ ``` bash
10+ phpcc -d src:php -d vendor:php -e main.php -o bin/foobar
11+ ```
12+ ## Example 2: Multiple extensions in the same directory
13+
14+ - Add all ` *.php ` and ` *.phtml ` files from ` src/ ` dir
15+ - Define ` main.php ` as the stub main entrypoint script
16+ - Save compiled phar executable to ` bin/foobar `
17+
18+ ``` bash
19+ phpcc -d src:php -d src:phtml -e main.php -o bin/foobar
20+ ```
21+
22+ ## Example 3: Standalone php script
23+
24+ - Define ` app.php ` as the stub main entrypoint script
25+ - Save compiled phar executable to ` foobar.phar `
26+ - Use ` LICENSE ` file contents as legal notice banner
27+
28+ ``` bash
29+ phpcc -e app.php -o foobar.phar -b LICENSE
30+ ```
You can’t perform that action at this time.
0 commit comments