Thx, nice tutorial ;) Could you show how to set a password for the zip-archive, too? ;) And, like Krister Johansson said, a "add-folder"-support? ;) Thx ;)
instead of unsetting the element from the array wouldn't it be more efficient to do all the zipping and checking if file exists within one forloop. sample code below \/ //open zip somewhere here, incase something goes wrong rest wont execute foreach($this->_files as $file){ if(file_exists($file){ $this->_zip->addFile($file, $file); }else{//do nothing} } //end foreach $this->_zip->close();
Its sort of funny. if you run the code over and over again, it will keep creating .zips, where the latest one contains a .zip of the previous zip, and so on. So if you name the file "myZip.zip" and run the code over and over the latest version of "myZip.zip" will contain all the previous copies of "myZip.zip" that you made before it.
to overcome this you can do elseif(preg_match('/.zip$/', $file)){ unset($this->_files[$index]); } after the "if(!file_exists($file)){" in the store function. This regex will see if the $file ends with .zip and remove it from the array of files to compress
You should add support for folders, ->add(folder / folder)
thank you alex for this awesome(as usual) tutorial
Good tutorial, but do you have a way that also backs up subfolders?
Thx, nice tutorial ;)
Could you show how to set a password for the zip-archive, too? ;) And, like Krister Johansson said, a "add-folder"-support? ;)
Thx ;)
Luggi Lindner This is currently not possible with PHP, You have to do it trough a command line. Or with a Archiver. :/
instead of unsetting the element from the array wouldn't it be more efficient
to do all the zipping and checking if file exists within one forloop.
sample code below \/
//open zip somewhere here, incase something goes wrong rest wont execute
foreach($this->_files as $file){
if(file_exists($file){
$this->_zip->addFile($file, $file);
}else{//do nothing}
} //end foreach
$this->_zip->close();
that is more simple and efficient, great thumbs up
Nice!
Its sort of funny. if you run the code over and over again, it will keep creating .zips, where the latest one contains a .zip of the previous zip, and so on. So if you name the file "myZip.zip" and run the code over and over the latest version of "myZip.zip" will contain all the previous copies of "myZip.zip" that you made before it.
to overcome this you can do
elseif(preg_match('/.zip$/', $file)){
unset($this->_files[$index]);
}
after the "if(!file_exists($file)){" in the store function.
This regex will see if the $file ends with .zip and remove it from the array of files to compress
what's the theme you are using in sublime?
hes using mac classic
thannnnnnnnnk youuuuuuuuuuuuuuuu