Skip to content

Commit e97f68c

Browse files
committed
Option to set runtime memory limit
php-obfuscator may run out of memory when parsing large and/or complicated PHP files. Use this option to increase the memory limit `bin/obfuscate obfuscate --memory_limit=128M <input directory>`
1 parent 8838048 commit e97f68c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/Naneau/Obfuscator/Console/Command/ObfuscateCommand.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ protected function configure()
7575
null,
7676
InputOption::VALUE_REQUIRED,
7777
'Configuration file to use'
78+
)->addOption(
79+
'memory_limit',
80+
null,
81+
InputOption::VALUE_REQUIRED,
82+
'Runtime memory when running the obsfucator. ' .
83+
'Example: 128M ' .
84+
'See http://php.net/manual/en/ini.core.php#ini.memory-limit'
7885
);
7986

8087
$this->setContainer(new Container);
@@ -92,6 +99,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
9299
// Finalize the container
93100
$this->finalizeContainer($input);
94101

102+
// Change runtime memory
103+
if($memory = $input->getOption('memory_limit')) {
104+
ini_set("memory_limit", $memory);
105+
}
95106
// Input/output dirs
96107
$inputDirectory = $input->getArgument('input_directory');
97108
$outputDirectory = $input->getArgument('output_directory');

0 commit comments

Comments
 (0)