Create a zip file from a list of selected files and make the zipped file downloadable in Drupal 8 How to create zip file programatically based on the files selected in Drupal 8? Is there any class already existing in Drupal 8?

As per below answer I'm using following code to generate zip file:

$file = \Drupal\file\Entity\File::load($fileId);
$fileUri = \Drupal::service('file_system')-&gt;realpath($file-&gt;getFileUri());

$zip = \Drupal::service('plugin.manager.archiver')-&gt;getInstance(['f‌​ilepath' =&gt; '/foo/bar.zip']);
$zip-&gt;add($fileUri);



The bar.zip file above should exist in the referenced path above: /foo/bar.zip.
Also how do I flatten the the zip file folder structure so that the file sites/default/files/myimage.png is myimage.png?
Use the ArchiverManager and get the instance by calling the getInstance() method. A Zip class is returned. The Drupal Zip class uses PHP's ZipArchive class to perform the heavy lifting.

Example (edited after remark @Clive):

$file = \Drupal\file\Entity\File::load($fileId);
$fileUri = \Drupal::service('file_system')-&gt;realpath($file-&gt;getFileUri());

$zip = \Drupal::service('plugin.manager.archiver')-&gt;getInstance(['f‌​ilepath' =&gt; '/foo/bar.zip']);
$zip-&gt;add($fileUri);