Cut Your Zend Framework Application Upload Time by a Gazillion

Uploading applications built with Zend Framework (or any other Feature Rich Framework) via FTP/SFTP is just boring and takes too long. Not to mention the size of your own application and additional third party files that you may need to upload to your server.

One solution is to roll your own package that only includes the necessary components, another is to zip, upload and unzip.

For the time being I decided to choose the latter.

With just a quick review of the zip extension on php.net/zip, I found in the documentation a possible solution.

I added my two cents and ended up with this


<?php

$file = basename($_GET['file']);

$extractTo = realpath(dirname(__FILE__)) . '/' . time() . '/' ;

echo "Extracting $file to $extractTo";

$zip = new ZipArchive;

if ($zip->open($file) === TRUE) {
    $zip->extractTo($extractTo);
    $zip->close();
    echo ' - done';
} else {
    echo ' - failed';
}
?>

You then do a simple http://www.example.com/unpack.php?file=myapp.zip and your files are extracted in no time.

As you can see nothing fancy.

It creates a new folder within the same location you placed the script . The folder is named after the current timestamp to avoid overwrites.

As per usual, do the necessaries to protect this script.

How do you cut your upload time?

Tags: , , , , , ,