src/Repository/DeploymentBuilder.php
public function addArchive(string $file): self
    {
        if (!\is_file($file)) {
            throw new \InvalidArgumentException(\sprintf('Archive not found: "%s"', $file));
        }
        
        if (!\is_readable($file)) {
            throw new \RuntimeException(\sprintf('Archive not readable: "%s"', $file));
        }
        
        $zip = new \ZipArchive();
        $zip->open($file);
        
        try {
            for ($i = 0; $i < $zip->numFiles; $i++) {
                $stat = (array) $zip->statIndex($i);
                
                // This will skip empty files as well... need a better way to this eventually.
                if (empty($stat['size'])) {
                    continue;
                }
                
                $name = $zip->getNameIndex($i);
                
                // Cap memory at 256KB to allow for large deployments when necessary.
                $stream = new StringStream('', 262144);
                $resource = $zip->getStream($name);
                
                try {
                    while (!\feof($resource)) {
                        $stream->write(\fread($resource, 8192));
                    }
                    
                    $stream->rewind();
                } finally {
                    @\fclose($resource);
                }
                
                $this->resources[\trim(\str_replace('\\', '/', $name), '/')] = $stream;
            }
        } finally {
            @$zip->close();
        }
        
        return $this;
    }
public function addArchive(string $file): self
    {
        if (!\is_file($file)) {
            throw new \InvalidArgumentException(\sprintf('Archive not found: "%s"', $file));
        }
        
        if (!\is_readable($file)) {
            throw new \RuntimeException(\sprintf('Archive not readable: "%s"', $file));
        }
        
        $zip = new \ZipArchive();
        $zip->open($file);
        
        try {
            for ($i = 0; $i < $zip->numFiles; $i++) {
                $stat = (array) $zip->statIndex($i);
                
                // This will skip empty files as well... need a better way to this eventually.
                if (empty($stat['size'])) {
                    continue;
                }
                
                $name = $zip->getNameIndex($i);
                
                // Cap memory at 256KB to allow for large deployments when necessary.
                $stream = new StringStream('', 262144);
                $resource = $zip->getStream($name);
                
                try {
                    while (!\feof($resource)) {
                        $stream->write(\fread($resource, 8192));
                    }
                    
                    $stream->rewind();
                } finally {
                    @\fclose($resource);
                }
                
                $this->resources[\trim(\str_replace('\\', '/', $name), '/')] = $stream;
            }
        } finally {
            @$zip->close();
        }
        
        return $this;
    }
public function addArchive ( string $ file ) : self { if ( ! \ is_file ( $ file ) ) { throw new \ InvalidArgumentException ( \ sprintf ( 'Archive not found: "%s"' , $ file ) ) ; } if ( ! \ is_readable ( $ file ) ) { throw new \ RuntimeException ( \ sprintf ( 'Archive not readable: "%s"' , $ file ) ) ; } $ zip = new \ ZipArchive ( ) ; $ zip -> open ( $ file ) ; try { for ( $ i = 0 ; $ i < $ zip -> numFiles ; $ i ++ ) { $ stat = ( array ) $ zip -> statIndex ( $ i ) ; // This will skip empty files as well... need a better way to this eventually. if ( empty ( $ stat [ 'size' ] ) ) { continue ; } $ name = $ zip -> getNameIndex ( $ i ) ; // Cap memory at 256KB to allow for large deployments when necessary. $ stream = new StringStream ( '' , 262144 ) ; $ resource = $ zip -> getStream ( $ name ) ; try { while ( ! \ feof ( $ resource ) ) { $ stream -> write ( \ fread ( $ resource , 8192 ) ) ; } $ stream -> rewind ( ) ; } finally { @ \ fclose ( $ resource ) ; } $ this -> resources [ \ trim ( \ str_replace ( '\\' , '/' , $ name ) , '/' ) ] = $ stream ; } } finally { @ $ zip -> close ( ) ; } return $ this ; }
Add a ZIP archives file contents to the deployment.

@throws \InvalidArgumentException When the given archive could not be found.
@throws \RuntimeException When the given archive could not be read.
Add a ZIP archives file contents to the deployment .