Sponsored by HowLifeWorks
Who Gets To Use Unsold Cruise Cabins at Huge Discounts view!
howlifeworks.com - How to access once-in-a-lifetime trips at significantly less than full price
19 Comments
- timdorr, on 10/12/2007, -0/+4Uh, PEAR is a code repository. It's not an "engine system". The code from PEAR is written by hundreds of developers, so I'm not sure why you're passing such judgement on it without having used it all, or even fully understanding it.
- MannaPC, on 10/12/2007, -1/+5Evening guys,
I don't reccomend PEAR at all. It may have some neat stuff, but it is a bulky, poorly coded and slow PHP engine system. If you don't believe me, I can get people to back it including a dev for PHP.
But, it is still an interesting tutorial and idea so I will digg it for future use. Just keep in mind what I said ;).
Christopher - ogre2112, on 10/12/2007, -0/+2I've seen some sites where they have shown to you a list of modules you want added (and preconfigured) to your main download. Using PHP code similar to this you can then create your own zip file with everything the user wants.
- timdorr, on 10/12/2007, -2/+4"The entire article in 4 lines:"
include ('Archive/Zip.php');
$zipper = new Archive_Zip('output.zip');
$files = array('somefile.txt');
$zipper->create($files);
I win. - Rayor, on 10/12/2007, -0/+1I'm just curious, why would this be useful?
I'm not trying to say this is stupid, I just want to know. - raccettura, on 10/12/2007, -0/+1To be fair, PEAR is ok for occasional use in seldom-used parts of your codebase, but to build a site on top of PEAR code is just asking for trouble. It's bloated and still somewhat buggy.
- bornhj, on 10/12/2007, -3/+4Uh... that's nothing like the article. Not only does the article talk about ZIP files, not GZIP tarballs, but your example only compresses the files. It doesn't show the contents of the archive, remove files from the archive, or add more files to the archive. Read the article.
- skinrock, on 10/12/2007, -0/+1One example might be if you create custom reports for a site, such as an ecommerce site or marketing site, and want to allow the user to download these reports in a compressed format. You can use this to write these files to a zip and let the user download it that way.
- bryxal, on 10/12/2007, -0/+1if you just want a lightweight real quick full PHP implementation to create ZIP files i would strongly recommend looking at the Zipper class:
http://www.phpclasses.org/browse/package/2322.html
License: Freeware - neftaly, on 10/12/2007, -0/+1Digg's comment formatting did that, the quotes were originally escaped.
- thedillydotcom, on 10/12/2007, -0/+1neftaly, single quotes ftw... syntax error on line 3 otherwise
just sayin. - grimreaper, on 10/12/2007, -0/+1Anyone have a clue how to convert a Microsoft Word document to a PDF on the fly using PHP and no addition software like OpenOffice or EasyPDF SDK, or anything using the COM object?
- se7en11, on 10/12/2007, -0/+1@Rayor
I just had to do this for one of our companies web sites. Management wanted all the images from a certain group of books. So rather than making them go on the site and gather all 300 or so images, we made a small script that would query a database and tell us where the zip files where on the server. Then simply add them all the one big zip file and pass it through the header where it could be downloaded automaticly.
BTW: We used Linux's built in zip function rather than PEAR or any other PHP class. Seems to work like a charm. - skinrock, on 10/12/2007, -0/+0There are also other examples that let you create files on the fly, not just add pre-existing files. For instance you can use the PHP output buffer to write dynamic content to a "temporary" file, compress it, and allow the user to download it as a zip, and view the file you just "created". Just a point that there are many other solutions, and as was mentioned above, PEAR isn't necessarily the best way to go, especially if you just want zip functionality.
- inactive, on 10/12/2007, -0/+0PEAR as pointed out above is a code repository, where you can download premade classes or functions to perform any number of functions. You don't use PEAR in your program. You use PEAR to get stuff to use in your program. No different than Cheese Shop for Python or CPAN for Perl.
- thedillydotcom, on 10/12/2007, -0/+0just to clarify, by "pear could be more efficient" i meant "the rules of pear authoring"
- neftaly, on 10/12/2007, -6/+6The entire article in 4 lines:
<? header("Content-type: encoded/gzip");
header("Content-Decoded-Type: text/plain");
header("Content-Disposition: attachment; filename="hello.txt.gz"");
echo gzencode($data, 9); ?> - thedillydotcom, on 10/12/2007, -0/+0PEAR could be more efficient. Open source code does have a tendency to be more bulky than need be compared to something designed specifically for the purpose at hand. PEAR projects are nice as a convenience. Includes are something which typically take a good amount of time as well as serialize / unserialize. PEAR has rules for its projects which encourage more includes than might be necessary as a way to improve maintainability but do nothing for speed. In the past i've used hyped projects which werent written well, but under normal stressloads on a site it probably wont make a lick of difference one way or another.
Truth is, PHP's never been a bottleneck for our projects. It always ends up being MySQL that takes the most time. Apache servers are cheap to toss together and easy to setup. If PEAR makes it easier, then unless you're worrying about a downpour of traffic I wouldnt let it deter anyone from adoption just because it might be a few miliseconds slower for php to render.
Just my $.02 - brendanc, on 10/12/2007, -4/+2Sounds a lot easier your way...


What is Digg?