Interested in learning PHP? Check out Easy-peasy PHP
PHP & MySQL
PHP Progress Bar
An interesting idea was posted to eVolt’s TheList in the form of a tip: using PHP’s flushing buffer to create a progress bar for large PHP applications. Juha Suni, the author of the tip, provided the following code, noting, that “you can use the flush()-function to push more data to the browser while the script is running. This data being elements for small pieces of the progress bar, you can rather easily have a universal solution for all heavy scripts”. The code below is as posted, the only changes are a couple of formatting tweaks for display on this site. I haven’t implemented it as of yet, so I can’t vouch for it’s functionality.
ob_end_flush(); // This should be called at start
// Load all data and process it ready for looping
// Do some preliminary calculations, such as:
$totalloops = 38;
$percent_per_loop = 100 / $totalloops;
$prev_percent = 0;
// print html/css for the part above the progress bar
// as well as possible background of the actual progress bar
// in such a way that the images for the progress bar (coming next)
// align themselves nicely
// (This example fits 100 images next to each other, each
// representing 1 percent of progress.
// Start looping:
for($i=1;$i< =$totalloops;$i++) {
// do stuff
// echo progress if at least an advance of 1 percent
// occured since last loop
$percent_now = round($i * $percent_per_loop);
if($percent_now != $percent_last) {
$difference = $percent_now - $percent_last;
for($j=1;$j<=$difference;$j++) {
echo '';
}
$percent_last = $percent_now;
flush(); // Push the new data to the browser;
}
}
// In the end print necessary code to the end of the html.
Juha notes, “on some occasions, the webserver, proxy or the client browser can buffer data no matter what you do, so this will not work 100% for everyone at every situation”. Still, this is a great idea, and one sorely needed for some major PHP apps.
Update: Juha has posted a nice demo of the script (no longer live), which “loops the sleep(1)-command for 14 times”. He also added a counter that displays the percentage that has been completed. Juha mentioned that he hopes to find the time to clean it up and implement the counter as a package for use in other scripts and projects. That would be great to see!
Update 2: Juha has posted a zipped up collection (see update 3 below) of the PHP source files and associated images.
Update 3: It appears that Juha’s site is down. I don’t have a demo to point to, but it appears someone else posted the script, which you can find here.
bbPress
From the developers of WordPress comes bbPress, a new, light weight forum package that follows five key principles (as taken from their site):
> 1. Open Source, always and forever
> 2. Less (code) is more
> 3. Simplicity is a feature
> 4. Speed and security are the foundation of any good user experience
> 5. Put the user first
>
> Every line of code is written with these principles in mind..
bbPress can be seen in action in the WordPress Support area, so check that area out for a demonstration of what it can do. For those who have visited the WordPress Support area in the past, you will be pleased with the fact that the forums are much faster.
Testing PHP
Testing PHP – “The Perl community has embraced testing as a key component of a developer’s skillset, whereas the PHP community still relies heavily upon echo and manual testing with a browser. Since Geoff is a Perl guy, I’m a PHP guy, and we happen to be good friends, we decided to create a way to let PHP developers benefit from Perl’s mature testing tools and methodologies. Since Geoff is really a mod_perl guy and interested in all things Apache, he is a big fan of the Apache-Test framework. This seemed like a great tool to provide to PHP developers, so we proposed a talk about it. Once the talk was accepted, we had to deliver.”
CaRP: Freeware Caching RSS news feed Parser
SilverSpider PlayList 1.0
A quick note to announce the public release of SilverSpider Play List, a set of PHP scripts that helps you add a recent music list to your Web site. Each time you listen to a song, your media player will send song information to your Web site which will gather the info, and with the help of Amazon, compile it into a list of entries, each containing the name of the song, the artist and the album cover.