File upload progress meter for PHP 4, at last!
The story of the PHPClasses site and the forms class- Form file upload progress meter- File upload progress meter for PHP 4- Upload progress meter plug-in- Merry X-mas and Happy New Year
This year has been very intense in terms of PHP developments, at least for me. I could talk about the the upcoming premium services, that are almost ready for launch. I could also talk about several PHP conferences that I have attended as a speaker. But no, I have already talked a lot about those subjects in previous posts.
In this end of year post, I will be talking about a single PHP class. Not just any class, but the class that made me create the PHPClasses site: Forms Generation and Validation.
http://www.phpclasses.org/formsgeneration
But let me tell you why this class is so important to PHPClasses site and also tens of thousands of PHP developers that use it.
- The story of the PHPClasses site and the forms class
I have started working with PHP around 1997, still in the PHP 2 beta days. I used to participate in PHP mailing lists a lot, like for instance in the php-general list. I still do, but not as frequently as then. I was learning about PHP and exchanging experiences with other PHP users.
When PHP 3 was launched in 1998 in opened up a new world of possibilities with the introduction of basic Object Oriented Programming (OOP) support. OOP classes provide a much better way to organize functions and variables associated to objects. It allows developers to encapsulate functionality that facilitates reuse and sharing code between projects, and also sharing with other people.
In January 1999 I started working on a class that would solve a recurring need of Web applications: generating and validating Web forms. The main goal was to generate HTML with embedded Javascript that would allow me to quickly deploy Web based forms.
The class should be able to validate forms on the server side, as well generate all the Javascript code to perform the same validations on the browser side, without requiring me to write Javascript by hand. This was one of the most important productivity factors that motivated the development of this class.
Once in while someone popped in the php-general mailing list asking about solutions to generate and validate forms. Then I talked about my class and suggested to contact me off the list, so I could share the class code. When the users contacted me, I could keep track of their e-mail addresses, so I could notify them later when a new version was available.
One day of June 1999, one of the early class users from Australia, named Robert Chalmers, after receiving the class from me by e-mail, was so happy about it that he posted back to the list praising the class.
http://marc.theaimsgroup.com/?m=92856190403431
When I saw that message I was stunned and blushed. I was not exactly looking for public recognition, although it was very nice of Robert. I was mainly interested to get as many users as possible to test the class, and hopefully report bugs and suggest new features.
http://marc.theaimsgroup.com/?m=92863569411920
Anyway, what followed was even more overwhelming. All of the sudden, I started receiving tens of requests from other users that followed Robert's advice and contacted me to get a copy of the class.
It was nice but it quickly became inviable to distribute the class by e-mail to anyone that wanted it. That made me look for a good online repository where I could distribute the class and keep the users in touch to be notified about new versions.
I looked at PX - PHP Code Exchange, written by David Sklar, which by the way it is still running until today.
http://px.sklar.com/
PX was almost perfect. The only problem is that it had no way to keep track of the users that downloaded the scripts, so they could be notified when a new version was released.
I contacted David and proposed to implement that feature. He was not interested, despite I offered myself to develop the necessary code. That is ok. After all it is his site and he is the one to decide what is or is not interesting. So, I respected his decision.
Then I decided to implement my own repository. In less than a week after I started, the PHP Classes Repository site was finally launched.
http://marc.theaimsgroup.com/?m=93020963511392
In the beginning it was meant only to distribute my own classes, but some time later I opened it to accept contributions by others. The rest is history.
- Form file upload progress meter
The forms class has been greatly enhanced over the years. In 2004 I added the ability to implement new types of inputs using plug-in classes. More recently I have developed the ability to submit forms using AJAX requests, which allowed to implement sophisticated controls like linked select inputs and auto-complete text inputs.
Last November PHP 5.2 was released. It finally integrated a patch originally developed by Doru Petrescu. It was submitted to the PHP core developers in 2003.
http://marc.theaimsgroup.com/?m=105484776324195
I have no idea why it took more than 3 years to accept and adapt the patch, as being able to monitor file upload progress was one of the most wished features by many PHP users.
Anyway, PHP 5.2 alone only provides the hooks to monitor file upload progress. To actually monitor the progress, it is necessary to use an extension that retrieves upload progress statistics and makes it available to another PHP script running in parallel.
Meanwhile Christian Stocker has submitted upload progress meter extension also based on the original work contributed by Doru.
http://blog.bitflux.ch/archive/2006/09/10/upload-progress-me ...
The actual extension is currently available from the PECL repository:
http://pecl.php.net/package/uploadprogress
Christian also announced the Windows version of this extension as a pre-compiled DLL:
http://blog.bitflux.ch/archive/2006/12/05/upload-progress-me ...
- File upload progress meter for PHP 4
The upload progress meter feature is great, especially for sites that take large file uploads. The problem is that almost 90% of the PHP sites still use PHP 4 and have no plans to upgrade the PHP 5.2 any time soon.
As a side comment, I would like to mention that I am intrigued of why certain PHP core developers still wonder why PHP 5 adoption does not pick up.
http://ilia.ws/archives/147-Why-are-you-not-using-PHP-5.html
The way I see it, the reason to not move to PHP 5 is simple: cost. It costs a lot of time and money to audit and change the code of existing sites to make them work with PHP 5 changes.
I am not only talking about documented changes. I am also talking about a lot of undocumented backwards incompatible changes that make an hell to everybody that needs to migrate reasonably sized sites.
Since a lot of developers and site owners do not want to migrate to PHP 5, hosting companies also do not migrate their servers currently running PHP 4, or else it will cost them a lot with the eventual loss of customers annoyed with their sites broken with PHP 5.
I am afraid that the whole PHP 5 version series is doomed to never pickup. I suspect that the actual growth of PHP 5 is less than the growth of the overall PHP adoption. Therefore, my advice to PHP core developers is to focus on PHP 6, and this time give up any ideas of making backwards incompatible changes.
The PHPClasses site is one of those sites that uses PHP 4 and is not expected to migrate to a newer version soon, especially because it is over 100,000 lines of code. Large code base sites not migrating to PHP 5 is normal. Even Zend has sites running on PHP 4 that they do not intend to migrate to PHP 5.
http://andigutmans.blogspot.com/2006/07/php-5-adoption-has-t ...
Since I wanted to use this upload progress meter extension under PHP 4, I had to find an alternative solution. I decided to port the patch that adds hooks to monitor upload progress to make it run under PHP 4.
If you are interested, you may find the patch to make it work under PHP 4.3.11:
http://www.phpclasses.org/browse/file/17423.html
and also under PHP 4.4.4:
http://www.phpclasses.org/browse/file/17424.html
Just let me know if you would like to have a patch that works with other PHP versions, or if you have difficulties to install these patches.
- Upload progress meter plug-in
Since you file upload uses forms, it is only natural for me to develop a plug-in for the forms class to provide any easy to deploy upload progress meter solution. I have been developing that plug-in recently and I have just released it as part of the forms class distribution.
http://www.phpclasses.org/formsgeneration
The upload progress meter already shows in the package file upload pages of the PHPClasses site. If you want to see it in action, you may try it here in this forms examples page:
http://www.meta-language.net/forms-examples.html?example=tes ...
Here you can view the example code to see how easy it is, all without writing a single line of Javascript:
http://www.meta-language.net/forms-examples.html?example=tes ...
The plug-in uses COMET based AJAX solution to provide fast progress bar update. COMET is a much better solution for this situation than using XMLHttpRequest based AJAX.
COMET requests only establish one HTTP connection. There is no need to keep polling the server to get updates, like when you use XMLHttpRequest. With COMET, the upload monitor HTTP request is kept running until the upload finishes. This way the progress bar and statistics updates are sent very quickly to the browser.
As I also recommended in a past post that if you use mod_gzip, you may need to turn off compression for the pages that serve the upload progress requests. Otherwise, mod_gzip buffers the whole COMET response and no progress bar updates are seen.
http://www.phpclasses.org/blog/post/58-Responsive-AJAX-appli ...
- Merry X-mas and Happy New Year
Well, it is almost X-mas and it is time to rest for while, for me and to everybody that has been working hard to make PHP the best solution to solve your Web problems.
I will try to respond in the next days any questions that you may have about these subjects, but if I do not speak to you sooner, have a Merry X-mas and Happy New Year 2007 .
This year has been very intense in terms of PHP developments, at least for me. I could talk about the the upcoming premium services, that are almost ready for launch. I could also talk about several PHP conferences that I have attended as a speaker. But no, I have already talked a lot about those subjects in previous posts.
In this end of year post, I will be talking about a single PHP class. Not just any class, but the class that made me create the PHPClasses site: Forms Generation and Validation.
http://www.phpclasses.org/formsgeneration
But let me tell you why this class is so important to PHPClasses site and also tens of thousands of PHP developers that use it.
- The story of the PHPClasses site and the forms class
I have started working with PHP around 1997, still in the PHP 2 beta days. I used to participate in PHP mailing lists a lot, like for instance in the php-general list. I still do, but not as frequently as then. I was learning about PHP and exchanging experiences with other PHP users.
When PHP 3 was launched in 1998 in opened up a new world of possibilities with the introduction of basic Object Oriented Programming (OOP) support. OOP classes provide a much better way to organize functions and variables associated to objects. It allows developers to encapsulate functionality that facilitates reuse and sharing code between projects, and also sharing with other people.
In January 1999 I started working on a class that would solve a recurring need of Web applications: generating and validating Web forms. The main goal was to generate HTML with embedded Javascript that would allow me to quickly deploy Web based forms.
The class should be able to validate forms on the server side, as well generate all the Javascript code to perform the same validations on the browser side, without requiring me to write Javascript by hand. This was one of the most important productivity factors that motivated the development of this class.
Once in while someone popped in the php-general mailing list asking about solutions to generate and validate forms. Then I talked about my class and suggested to contact me off the list, so I could share the class code. When the users contacted me, I could keep track of their e-mail addresses, so I could notify them later when a new version was available.
One day of June 1999, one of the early class users from Australia, named Robert Chalmers, after receiving the class from me by e-mail, was so happy about it that he posted back to the list praising the class.
http://marc.theaimsgroup.com/?m=92856190403431
When I saw that message I was stunned and blushed. I was not exactly looking for public recognition, although it was very nice of Robert. I was mainly interested to get as many users as possible to test the class, and hopefully report bugs and suggest new features.
http://marc.theaimsgroup.com/?m=92863569411920
Anyway, what followed was even more overwhelming. All of the sudden, I started receiving tens of requests from other users that followed Robert's advice and contacted me to get a copy of the class.
It was nice but it quickly became inviable to distribute the class by e-mail to anyone that wanted it. That made me look for a good online repository where I could distribute the class and keep the users in touch to be notified about new versions.
I looked at PX - PHP Code Exchange, written by David Sklar, which by the way it is still running until today.
http://px.sklar.com/
PX was almost perfect. The only problem is that it had no way to keep track of the users that downloaded the scripts, so they could be notified when a new version was released.
I contacted David and proposed to implement that feature. He was not interested, despite I offered myself to develop the necessary code. That is ok. After all it is his site and he is the one to decide what is or is not interesting. So, I respected his decision.
Then I decided to implement my own repository. In less than a week after I started, the PHP Classes Repository site was finally launched.
http://marc.theaimsgroup.com/?m=93020963511392
In the beginning it was meant only to distribute my own classes, but some time later I opened it to accept contributions by others. The rest is history.
- Form file upload progress meter
The forms class has been greatly enhanced over the years. In 2004 I added the ability to implement new types of inputs using plug-in classes. More recently I have developed the ability to submit forms using AJAX requests, which allowed to implement sophisticated controls like linked select inputs and auto-complete text inputs.
Last November PHP 5.2 was released. It finally integrated a patch originally developed by Doru Petrescu. It was submitted to the PHP core developers in 2003.
http://marc.theaimsgroup.com/?m=105484776324195
I have no idea why it took more than 3 years to accept and adapt the patch, as being able to monitor file upload progress was one of the most wished features by many PHP users.
Anyway, PHP 5.2 alone only provides the hooks to monitor file upload progress. To actually monitor the progress, it is necessary to use an extension that retrieves upload progress statistics and makes it available to another PHP script running in parallel.
Meanwhile Christian Stocker has submitted upload progress meter extension also based on the original work contributed by Doru.
http://blog.bitflux.ch/archive/2006/09/10/upload-progress-me ...
The actual extension is currently available from the PECL repository:
http://pecl.php.net/package/uploadprogress
Christian also announced the Windows version of this extension as a pre-compiled DLL:
http://blog.bitflux.ch/archive/2006/12/05/upload-progress-me ...
- File upload progress meter for PHP 4
The upload progress meter feature is great, especially for sites that take large file uploads. The problem is that almost 90% of the PHP sites still use PHP 4 and have no plans to upgrade the PHP 5.2 any time soon.
As a side comment, I would like to mention that I am intrigued of why certain PHP core developers still wonder why PHP 5 adoption does not pick up.
http://ilia.ws/archives/147-Why-are-you-not-using-PHP-5.html
The way I see it, the reason to not move to PHP 5 is simple: cost. It costs a lot of time and money to audit and change the code of existing sites to make them work with PHP 5 changes.
I am not only talking about documented changes. I am also talking about a lot of undocumented backwards incompatible changes that make an hell to everybody that needs to migrate reasonably sized sites.
Since a lot of developers and site owners do not want to migrate to PHP 5, hosting companies also do not migrate their servers currently running PHP 4, or else it will cost them a lot with the eventual loss of customers annoyed with their sites broken with PHP 5.
I am afraid that the whole PHP 5 version series is doomed to never pickup. I suspect that the actual growth of PHP 5 is less than the growth of the overall PHP adoption. Therefore, my advice to PHP core developers is to focus on PHP 6, and this time give up any ideas of making backwards incompatible changes.
The PHPClasses site is one of those sites that uses PHP 4 and is not expected to migrate to a newer version soon, especially because it is over 100,000 lines of code. Large code base sites not migrating to PHP 5 is normal. Even Zend has sites running on PHP 4 that they do not intend to migrate to PHP 5.
http://andigutmans.blogspot.com/2006/07/php-5-adoption-has-t ...
Since I wanted to use this upload progress meter extension under PHP 4, I had to find an alternative solution. I decided to port the patch that adds hooks to monitor upload progress to make it run under PHP 4.
If you are interested, you may find the patch to make it work under PHP 4.3.11:
http://www.phpclasses.org/browse/file/17423.html
and also under PHP 4.4.4:
http://www.phpclasses.org/browse/file/17424.html
Just let me know if you would like to have a patch that works with other PHP versions, or if you have difficulties to install these patches.
- Upload progress meter plug-in
Since you file upload uses forms, it is only natural for me to develop a plug-in for the forms class to provide any easy to deploy upload progress meter solution. I have been developing that plug-in recently and I have just released it as part of the forms class distribution.
http://www.phpclasses.org/formsgeneration
The upload progress meter already shows in the package file upload pages of the PHPClasses site. If you want to see it in action, you may try it here in this forms examples page:
http://www.meta-language.net/forms-examples.html?example=tes ...
Here you can view the example code to see how easy it is, all without writing a single line of Javascript:
http://www.meta-language.net/forms-examples.html?example=tes ...
The plug-in uses COMET based AJAX solution to provide fast progress bar update. COMET is a much better solution for this situation than using XMLHttpRequest based AJAX.
COMET requests only establish one HTTP connection. There is no need to keep polling the server to get updates, like when you use XMLHttpRequest. With COMET, the upload monitor HTTP request is kept running until the upload finishes. This way the progress bar and statistics updates are sent very quickly to the browser.
As I also recommended in a past post that if you use mod_gzip, you may need to turn off compression for the pages that serve the upload progress requests. Otherwise, mod_gzip buffers the whole COMET response and no progress bar updates are seen.
http://www.phpclasses.org/blog/post/58-Responsive-AJAX-appli ...
- Merry X-mas and Happy New Year
Well, it is almost X-mas and it is time to rest for while, for me and to everybody that has been working hard to make PHP the best solution to solve your Web problems.
I will try to respond in the next days any questions that you may have about these subjects, but if I do not speak to you sooner, have a Merry X-mas and Happy New Year 2007 .
Comments