Mage/Compiler.php
/**
     * Compiles the library
     *
     * @param string $file
     */
Compiles the library
@param string $file
Compiles the library @param string $file
public function compile($file = 'mage.phar')
    {
        if (file_exists($file)) {
            unlink($file);
        }
        $phar = new Phar($file, 0, 'mage.phar');
        $phar->setSignatureAlgorithm(Phar::SHA1);
        $phar->startBuffering();
        $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(__DIR__), RecursiveIteratorIterator::CHILD_FIRST);
        foreach ($iterator as $path) {
            if ($path->isFile()) {
                $phar->addFromString(str_replace(dirname(__DIR__).'/', '', $path->getPathname()), file_get_contents($path));
            }
        }
        $binary = file(__DIR__.'/../bin/mage');
        unset($binary[0]);
        $binary = implode(PHP_EOL, $binary);
        $phar->addFromString('mage', str_replace(
            '$baseDir = dirname(dirname(__FILE__));',
            '$baseDir = __DIR__;',
    		$binary
        ));
        $phar->setStub("#!/usr/bin/env php\n<?php Phar::mapPhar('mage.phar'); require 'phar://mage.phar/mage'; __HALT_COMPILER();");
        $phar->stopBuffering();
        unset($phar);
        chmod($file, 0755);
    }
public function compile ( $ file = 'mage.phar' ) { if ( file_exists ( $ file ) ) { unlink ( $ file ) ; } $ phar = new Phar ( $ file , 0 , 'mage.phar' ) ; $ phar -> setSignatureAlgorithm ( Phar :: SHA1 ) ; $ phar -> startBuffering ( ) ; $ iterator = new RecursiveIteratorIterator ( new RecursiveDirectoryIterator ( __DIR__ ) , RecursiveIteratorIterator :: CHILD_FIRST ) ; foreach ( $ iterator as $ path ) { if ( $ path -> isFile ( ) ) { $ phar -> addFromString ( str_replace ( dirname ( __DIR__ ) . '/' , '' , $ path -> getPathname ( ) ) , file_get_contents ( $ path ) ) ; } } $ binary = file ( __DIR__ . '/../bin/mage' ) ; unset ( $ binary [ 0 ] ) ; $ binary = implode ( PHP_EOL , $ binary ) ; $ phar -> addFromString ( 'mage' , str_replace ( '$baseDir = dirname(dirname(__FILE__));' , '$baseDir = __DIR__;' , $ binary ) ) ; $ phar -> setStub ( " #!/usr/bin/env php \n <?php Phar::mapPhar('mage.phar'); require 'phar://mage.phar/mage'; __HALT_COMPILER(); " ) ; $ phar -> stopBuffering ( ) ; unset ( $ phar ) ; chmod ( $ file , 0755 ) ; }
Compiles the library
 @param string $file
Compiles the library @param string $file
/** @var $path SplFileInfo */