Skip to content

Commit 86aee53

Browse files
committed
Runtime: Add --debug option
1 parent eb0dce8 commit 86aee53

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ phpcc \
3636
[-f <file> [-f <file> ...]] \
3737
[-b <banner>] \
3838
[-m <metadata> [-m <metadata> ...]]
39+
[--debug]
3940
```
4041

4142
### Options/Arguments
@@ -52,6 +53,7 @@ Name / Shorthand | Type | Description
5253
`--meta`, `-m` | multi | Adds a metadata to the archive<br/>_Metadata must be specified in the `$key:$value` format_ |n
5354
`--no-minify`, `-n` | flag | Don't minify PHP source files<br/>_Useful for debugging the compiled executable in case of runtime errors_ |n
5455
`--shebang-less` | flag | Produce a stub deprived of the shebang directive<br/>_Useful when the phar is meant to be included instead of being executed directly_ |n
56+
`--debug` | flag | Turn on debug mode<br/>*Set php error reporting level to `E_ALL` at compilation time* |n
5557
`--quiet`, `-q` | flag | Reduce output messages amount: set verbosity level to `INFO` instead of default `DEBUG` |n
5658

5759

src/Command/Compile.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public function configure()
4747
->addOption('banner', 'b', Option::VALUE, 'Load legal notice from the given banner file')
4848
->addOption('shebang-less', '', Option::FLAG, 'Produce a stub deprived of the shebang directive')
4949
->addOption('no-minify', 'n', Option::FLAG, "Don't minify php source files")
50+
->addOption('debug', '', Option::FLAG, 'Turn on debugging mode (increase verbosity and error_reporting level)')
5051
// Global options
5152
->addOption('quiet', 'q', Option::FLAG, 'Set output verbosity level to INFO instead of DEBUG')
5253
;
@@ -57,6 +58,13 @@ public function configure()
5758
*/
5859
public function execute()
5960
{
61+
$debug = $this->getOption('debug');
62+
63+
// In debug mode, catch and log all errors
64+
if ($debug) {
65+
error_reporting(E_ALL);
66+
}
67+
6068
$banner = $this->getOption('banner') ?? '';
6169

6270
$dirs = $this->getOption('dir') ?? [];

0 commit comments

Comments
 (0)