In PHP, ZipArchive Class is used for creating a zip file.
For adding a whole directory files need to read directory files one by one and add in the ZipArchive Class object.
CodeIgniter already provided zip library which allows to either add files or a directory for Compress.
Need to load the zip library for using it.
In this tutorial, I show how you can create a zip file, download, and save it to the server with CodeIgniter.