public function create($phar_path = 'environaut.phar')
    {
        if (file_exists($phar_path)) {
            unlink($phar_path);
        }

        $phar = new \Phar($phar_path, 0, 'environaut.phar');

        $phar->setSignatureAlgorithm(\Phar::SHA1);

        $phar->startBuffering();

        $root_dir = dirname(dirname(__DIR__));

        // add environaut files
        $finder = new Finder();

        $finder->files()->notName('PharCompiler.php')->in($root_dir . '/src');

        foreach ($finder as $file) {
            $phar->addFile($file->getRealPath(), 'src/' . $file->getRelativePathname());
        }

        // add vendor files using a whitelist with excludes
        $finder = new Finder();
        $finder->files()
            ->name('*.php')
            ->name('security\.sensiolabs\.org\.crt')
            ->path('/symfony\/console\//')
            ->path('/sensiolabs\/security-checker\//')
            ->notName('SecurityCheckerCommand.php')
            ->notPath('/(\/Tests\/|\/Tester\/)/')
            ->in($root_dir . '/vendor');

        foreach ($finder as $file) {
            $phar->addFile($file->getRealPath(), 'vendor/' . $file->getRelativePathname());
        }

        // add composer vendor autoloading
        $vendor_root_dir = $root_dir . '/vendor/';
        $phar->addFile($vendor_root_dir . 'autoload.php', 'vendor/autoload.php');
        $composer_dir = $vendor_root_dir . 'composer/';
        $phar->addFile($composer_dir . 'autoload_namespaces.php', 'vendor/composer/autoload_namespaces.php');
        $phar->addFile($composer_dir . 'autoload_classmap.php', 'vendor/composer/autoload_classmap.php');
        $phar->addFile($composer_dir . 'autoload_psr4.php', 'vendor/composer/autoload_psr4.php');
        $phar->addFile($composer_dir . 'autoload_real.php', 'vendor/composer/autoload_real.php');
        //$phar->addFile($composer_dir . 'include_paths.php', 'vendor/composer/include_paths.php');
        $phar->addFile($composer_dir . 'ClassLoader.php', 'vendor/composer/ClassLoader.php');

        // environaut executable
        $phar->addFile($root_dir . '/bin/environaut', 'bin/environaut');

        // additional markdown files like README.md or LICENSE.md
        $finder = new Finder();
        $finder->files()->name('*.md')->depth('== 0')->in($root_dir);
        foreach ($finder as $file) {
            $phar->addFile($file->getRealPath(), '/' . $file->getRelativePathname());
        }

        // add startup file
        $phar->setStub($this->getStub());

        $phar->stopBuffering();

        chmod($phar_path, 0755);
    }
public function create($phar_path = 'environaut.phar')
    {
        if (file_exists($phar_path)) {
            unlink($phar_path);
        }

        $phar = new \Phar($phar_path, 0, 'environaut.phar');

        $phar->setSignatureAlgorithm(\Phar::SHA1);

        $phar->startBuffering();

        $root_dir = dirname(dirname(__DIR__));

        // add environaut files
        $finder = new Finder();

        $finder->files()->notName('PharCompiler.php')->in($root_dir . '/src');

        foreach ($finder as $file) {
            $phar->addFile($file->getRealPath(), 'src/' . $file->getRelativePathname());
        }

        // add vendor files using a whitelist with excludes
        $finder = new Finder();
        $finder->files()
            ->name('*.php')
            ->name('security\.sensiolabs\.org\.crt')
            ->path('/symfony\/console\//')
            ->path('/sensiolabs\/security-checker\//')
            ->notName('SecurityCheckerCommand.php')
            ->notPath('/(\/Tests\/|\/Tester\/)/')
            ->in($root_dir . '/vendor');

        foreach ($finder as $file) {
            $phar->addFile($file->getRealPath(), 'vendor/' . $file->getRelativePathname());
        }

        // add composer vendor autoloading
        $vendor_root_dir = $root_dir . '/vendor/';
        $phar->addFile($vendor_root_dir . 'autoload.php', 'vendor/autoload.php');
        $composer_dir = $vendor_root_dir . 'composer/';
        $phar->addFile($composer_dir . 'autoload_namespaces.php', 'vendor/composer/autoload_namespaces.php');
        $phar->addFile($composer_dir . 'autoload_classmap.php', 'vendor/composer/autoload_classmap.php');
        $phar->addFile($composer_dir . 'autoload_psr4.php', 'vendor/composer/autoload_psr4.php');
        $phar->addFile($composer_dir . 'autoload_real.php', 'vendor/composer/autoload_real.php');
        //$phar->addFile($composer_dir . 'include_paths.php', 'vendor/composer/include_paths.php');
        $phar->addFile($composer_dir . 'ClassLoader.php', 'vendor/composer/ClassLoader.php');

        // environaut executable
        $phar->addFile($root_dir . '/bin/environaut', 'bin/environaut');

        // additional markdown files like README.md or LICENSE.md
        $finder = new Finder();
        $finder->files()->name('*.md')->depth('== 0')->in($root_dir);
        foreach ($finder as $file) {
            $phar->addFile($file->getRealPath(), '/' . $file->getRelativePathname());
        }

        // add startup file
        $phar->setStub($this->getStub());

        $phar->stopBuffering();

        chmod($phar_path, 0755);
    }
public function create ( $ phar_path = 'environaut.phar' ) { if ( file_exists ( $ phar_path ) ) { unlink ( $ phar_path ) ; } $ phar = new \ Phar ( $ phar_path , 0 , 'environaut.phar' ) ; $ phar -> setSignatureAlgorithm ( \ Phar :: SHA1 ) ; $ phar -> startBuffering ( ) ; $ root_dir = dirname ( dirname ( __DIR__ ) ) ; // add environaut files $ finder = new Finder ( ) ; $ finder -> files ( ) -> notName ( 'PharCompiler.php' ) -> in ( $ root_dir . '/src' ) ; foreach ( $ finder as $ file ) { $ phar -> addFile ( $ file -> getRealPath ( ) , 'src/' . $ file -> getRelativePathname ( ) ) ; } // add vendor files using a whitelist with excludes $ finder = new Finder ( ) ; $ finder -> files ( ) -> name ( '*.php' ) -> name ( 'security\.sensiolabs\.org\.crt' ) -> path ( '/symfony\/console\//' ) -> path ( '/sensiolabs\/security-checker\//' ) -> notName ( 'SecurityCheckerCommand.php' ) -> notPath ( '/(\/Tests\/|\/Tester\/)/' ) -> in ( $ root_dir . '/vendor' ) ; foreach ( $ finder as $ file ) { $ phar -> addFile ( $ file -> getRealPath ( ) , 'vendor/' . $ file -> getRelativePathname ( ) ) ; } // add composer vendor autoloading $ vendor_root_dir = $ root_dir . '/vendor/' ; $ phar -> addFile ( $ vendor_root_dir . 'autoload.php' , 'vendor/autoload.php' ) ; $ composer_dir = $ vendor_root_dir . 'composer/' ; $ phar -> addFile ( $ composer_dir . 'autoload_namespaces.php' , 'vendor/composer/autoload_namespaces.php' ) ; $ phar -> addFile ( $ composer_dir . 'autoload_classmap.php' , 'vendor/composer/autoload_classmap.php' ) ; $ phar -> addFile ( $ composer_dir . 'autoload_psr4.php' , 'vendor/composer/autoload_psr4.php' ) ; $ phar -> addFile ( $ composer_dir . 'autoload_real.php' , 'vendor/composer/autoload_real.php' ) ; //$phar->addFile($composer_dir . 'include_paths.php', 'vendor/composer/include_paths.php'); $ phar -> addFile ( $ composer_dir . 'ClassLoader.php' , 'vendor/composer/ClassLoader.php' ) ; // environaut executable $ phar -> addFile ( $ root_dir . '/bin/environaut' , 'bin/environaut' ) ; // additional markdown files like README.md or LICENSE.md $ finder = new Finder ( ) ; $ finder -> files ( ) -> name ( '*.md' ) -> depth ( '== 0' ) -> in ( $ root_dir ) ; foreach ( $ finder as $ file ) { $ phar -> addFile ( $ file -> getRealPath ( ) , '/' . $ file -> getRelativePathname ( ) ) ; } // add startup file $ phar -> setStub ( $ this -> getStub ( ) ) ; $ phar -> stopBuffering ( ) ; chmod ( $ phar_path , 0755 ) ; }
Creates a PHP archive file with all files necessary to
run Environaut standalone.

@param string $phar_path full path to the php archive file to create
Creates a PHP archive file with all files necessary to run Environaut standalone .