Tag

Archive

Browsing

Today, We are going to learn Laravel Extract zip/archive file using chumper/zipper. In the last article, we will learn how to create a zip file.  Also, We are going to use chumper zipper package to extract the zip file. First of all, We are going to install the package by the following command.

Laravel Extract zip/archive file using chumper/zipper

Once the package has installed we have to update the Providers and Aliases. Let’s open the config “config/app.php” file then append the Providers and Aliases like below.

The Chumper Zipper package is ready to use. Now, We going to extract the zip file. Let’s create the function to extract the zip file.

First of all, I get the zip file path for passing the first argument on the Zipper function. As a second argument, You should pass the valid directory where you want to extract the zip file. Now, run the code and check the zip file is an extract or not.

If you face any issue on extract zip file please write the comment below.

Today, We are going to learn programmatically PHP create ZIP file. PHP provides ZipArchive class using that we can easily create the zip file. But Today, I am going to share function with you using that function you can easily create the ZIP file by passing the directory name or file name.

Suddenly, My client tells me to move his project from one server to another server and his use the shared hosting. So, I have only FTP detail at that time I created “createZip” function for creating the zip file of files or directories. I am going to share that function with you So, you can easily create the zip file without hard work using PHP. You just need to write single line code for PHP creating ZIP file.

PHP create ZIP file

Just past the “createZip” function anywhere on your project then you just need to call that function for creating the zip file like

If you need to create the zip file of the current directory then you need to pass dot except for the directory path like

Or else you should pass the full directory path like

After, Creating the ZIP file if you want to move it another server without download it on your local system then You can follow my tutorial “Download Archive file from URL

If you face any issue after using this code please write the comment below.

Today, We are going to learn how to Download zip file from URL using PHP. PHP download archive file using single line of code. We can easily download the any file using PHP single line of code. We use file_put_contents for download file.

PHP Download Archive file

You can download any types of file using this function like JPG, JPEG, EXE, PNG, MP4, MP3 etc…

This trick is very useful when you want to move project to new server. We don’t need to download project to local system and then upload it to new server. Just create zip file of the project and create PHP script to new server then directly download project file on new server using PHP script.

If you face any problem after using this code please write a comment.