* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Mage\Command\BuiltIn; use Mage\Command\AbstractCommand; use Mage\Console; use Mage\Compiler; /** * Command for Compile Magallanes into a PHAR executable * * @author Ismael Ambrosi */ class CompileCommand extends AbstractCommand { /** * @var Compiler */ private $compiler; public function __construct(Compiler $compiler = null) { if ($compiler === null) { $compiler = new Compiler(); } $this->compiler = $compiler; $this->setName('Compile command') ->setHelpMessage('Compiles Magallanes to mage.phar file') ->setSyntaxMessage('mage compile'); } /** * @see \Mage\Compile::compile() */ public function run() { if (ini_get('phar.readonly')) { Console::output( 'The php.ini variable phar.readonly' . ' must be Off.', 1, 2 ); return 200; } $this->compiler->compile(); Console::output( 'mage.phar compiled successfully', 0, 2 ); return 0; } }