Does your site run as quickly as it could? It’s worth your time to find out. Faster web sites sell more products, improve user satisfaction, and even rank higher in Google searches.
Note: This tip was written for IBM i but could be adapted for other platforms as well.
Compression adds speed
IBM’s Apache web server provides a way to speed up your pages. You can compress PHP output, javascript, style sheets, and other text-based content. The compressed output will automatically be decompressed and interpreted properly by all modern web browsers. My tests show a speed improvement of 10-50% from this easy technique.
How to enable compression in 3 steps
1. Edit your Apache configuration file, located at /www/myserver/conf/httpd.conf (replace myserver with your instance name. This is a simple text file, so you may choose from several editors: IBM’s HTTP Server Admin GUI at port 2001 (if *ADMIN is started), the WRKLNK/EDTF command, or your favorite text editor.
2. Add the following two directives to the httpd.conf’s main section:
|
|
# Load IBM i's module that performs compression LoadModule deflate_module /QSYS.LIB/QHTTPSVR.LIB/QZSRCORE.SRVPGM # Specify what to compress (example: php, json, css, javascript, static html) AddOutputFilterByType DEFLATE application/x-httpd-php application/json text/css application/x-javascript application/javascript text/html |
3. Restart Apache via the HTTP Server Admin page or STRTCPSVR SERVER(*HTTP) RESTART(*HTTP) HTTPSVR(MYSERVER)
Measure the improvement
I ran before-and-after tests using a sample script included with Zend Server for IBM i: http://your-server:10088/Samples/SQL_access/DB2_SQL_example.php.
Before compression: 31kb, loaded in 250ms (milliseconds). See the Firebug report below (Firebug is an optional add-on for Firefox and is not required.)

Without compression, this page was 31kb and loaded in 250ms
After compression: 4.4kb; loaded in 109ms. That’s only 14% of the size and 50% of the time! See the screen shot below.

after compression: only 4.4kb and loaded in 109ms
I highly recommend that you give output compression a try. Your HTTP Server for IBM i pages will fly!
For more information on browser output compression, see: http://httpd.apache.org/docs/2.0/mod/mod_deflate.html
Rocking at COMMON
/3 Comments/in PHP /by Alan SeidenCOMMON’s fall conference and expo in San Antonio was the first of its kind, and a first for me as well. It marked my debut as a speaker for COMMON, as I presented three sessions about PHP on IBM i.
The conference brought the Power Systems and IBM i community together for learning and networking. I met many great people and caught up with industry friends.
After each day’s information-packed sessions, we gathered to relax and socialize.
A social highlight for me was the “Power Down” evening on Tuesday, October 5. The organizers had set up the Wii “Rock Band” game. This photo shows me on “drums,” Rich Nemerovsky singing, and Brian May playing “guitar.” I think Brian can actually play.
Alan Seiden, Rich Nemerovsky, and Brian May playing Wii “Rock Band”
Zend Framework named among “Best of Open Source Software” for 2010
/4 Comments/in PHP /by Alan SeidenInfoworld has awarded Zend Framework a “Bossie,” naming ZF one of the top 10 open source application development tools of 2010.
Infoworld says:
I agree that ZF’s “use at will” architecture provides major benefits. Last week I helped a client set up a SOAP client and server using Zend_Soap_Client and Zend_Soap_Server, all from within a normal PHP script. While I normally do use ZF’s full MVC architecture, it’s not required.
Congratulations to Zend Framework!
VTMUG friends
/0 Comments/in IBM i, PHP /by Alan SeidenI had a great time yesterday at the annual conference of VTMUG (Vermont Midrange Users Group). I gave two talks about PHP on IBM i. I got to watch Skip Marchesani give a talk about the IBM i’s SQL Script Center, and John Valance speaking about Web 2.0.
I wanted to see Jon Paris and Susan Gantner’s presentations but conflicting time slots prevented that. I’ll try to catch Susan’s talk at the Zend/PHP Conference, where I’ll also be speaking.
This photo shows us relaxing after a satisfying day of teaching and learning at VTMUG.
Relaxing after VTMUG's annual conference in South Burlington, Vermont
My upcoming PHP talks this fall (2010)
/2 Comments/in News & Events /by Alan SeidenPlease join me for my IBM i-focused PHP talks this fall. I’ll present these topics:
…all focused on PHP on IBM i!
Here are the dates, locations and web sites with more information:
Sept 28: Vermont Midrange Users Group (VTMUG) education day, South Burlington, Vermont
Oct. 3-6: COMMON Fall Conference, San Antonio, Texas
Oct. 26: OMNI Users Group education day, Chicago suburbs
Nov. 1-4: Zend/PHP Conference (ZendCon 2010), Santa Clara, California
I look forward to meeting many of you at these great conferences and education days.
Two techniques for retrieving SQL from Zend Framework’s database components
/8 Comments/in PHP /by Alan SeidenZend Framework’s database components can build and run queries without the developer’s having to touch the underlying SQL. Sometimes, though, developers need the SQL for diagnosing problems or to look for efficiencies. That SQL can be accessed with a choice of two main techniques:
getQuery()
getQuery() is a method of Zend_Db_Profiler and seems, along with getLastQueryProfile(), to be the standard advice for retrieving SQL of a recent query:
query = $profiler->getLastQueryProfile();echo $query->getQuery();Yes, getQuery() works, but what if I’m not using the profiler, or I need to retrieve SQL before a query has run?
__toString()
The “magic method” __toString() is simple and can be used either before or after the query is run. When applied to a Zend_Db_Select object, it generates an SQL string.
From the Zend_Db_Select documentation:
$select = $db->select()->from('products');$sql = $select->__toString();echo "$sql\n";// The output is the string:// SELECT * FROM "products"__toString() is simple to use, yet is often forgotten when discussing how to retrieve SQL from Zend_Db_Select. I recommend it.
Maximize PHP performance with Apache compression
/5 Comments/in Apache, IBM i, Performance, PHP, Web development /by Alan SeidenDoes your site run as quickly as it could? It’s worth your time to find out. Faster web sites sell more products, improve user satisfaction, and even rank higher in Google searches.
Note: This tip was written for IBM i but could be adapted for other platforms as well.
Compression adds speed
IBM’s Apache web server provides a way to speed up your pages. You can compress PHP output, javascript, style sheets, and other text-based content. The compressed output will automatically be decompressed and interpreted properly by all modern web browsers. My tests show a speed improvement of 10-50% from this easy technique.
How to enable compression in 3 steps
1. Edit your Apache configuration file, located at /www/myserver/conf/httpd.conf (replace myserver with your instance name. This is a simple text file, so you may choose from several editors: IBM’s HTTP Server Admin GUI at port 2001 (if *ADMIN is started), the WRKLNK/EDTF command, or your favorite text editor.
2. Add the following two directives to the httpd.conf’s main section:
3. Restart Apache via the HTTP Server Admin page or STRTCPSVR SERVER(*HTTP) RESTART(*HTTP) HTTPSVR(MYSERVER)
Measure the improvement
I ran before-and-after tests using a sample script included with Zend Server for IBM i: http://your-server:10088/Samples/SQL_access/DB2_SQL_example.php.
Before compression: 31kb, loaded in 250ms (milliseconds). See the Firebug report below (Firebug is an optional add-on for Firefox and is not required.)
Without compression, this page was 31kb and loaded in 250ms
After compression: 4.4kb; loaded in 109ms. That’s only 14% of the size and 50% of the time! See the screen shot below.
after compression: only 4.4kb and loaded in 109ms
I highly recommend that you give output compression a try. Your HTTP Server for IBM i pages will fly!
For more information on browser output compression, see: http://httpd.apache.org/docs/2.0/mod/mod_deflate.html
Zend Studio 7.2.1 faster, more reliable
/2 Comments/in IBM i, PHP /by Alan SeidenUPDATE: As of 2020, we recommend using Seiden PHP on IBM i and LINUX for reliability, speed, and ease of maintenance.
I just upgraded my copy of Zend Studio for IBM i from 7.0.2 to 7.2.1. Big improvement!
My use case: I typically use Zend Studio’s “Remote Server” facility to connect to the IBM i over FTP. With 7.2.1, FTP-based files now open and save much faster than before. In addition, the FTP connection no longer randomly disconnects the way it used to.
I recommend upgrading to 7.2.1, especially for anyone using FTP. It provides a smooth, hassle-free user experience.
Get Zend Studio here: http://www.zend.com/en/products/studio/downloads. Scroll down to the edition you need.
Note: this product is still free to users of IBM i, a nice benefit of Zend’s relationship with IBM.
A simple security measure
/2 Comments/in Apache, PHP, Web development /by Alan SeidenA reader recently asked me this security question:
The solution is to turn off directory browsing in your Apache configuration. To do this, make sure your Apache configuration file (probably httpd.conf or .htaccess) includes this directive:
Options -Indexes
Note that this directive merely prevents people from discovering the names of your files. Users who already know your file names can still access them. But Options -Indexes provides an important layer of security, preventing mischief from casual users who might otherwise stumble onto your file names by accident or design.
More information: http://httpd.apache.org/docs/2.2/mod/core.html#options
See me speak about web services and Zend Framework
/1 Comment/in News & Events /by Alan SeidenJoin me at at Long Island PHP on June 7, 2010, where I’ll present a case study showing how I integrated Windows-based data into an IBM i-based application using SOAP with Zend Framework.
The principles are the same no matter what type of servers you use.
There will be plenty of time for questions and discussion.
Hope to see you there!
P.S. To see the slides from my past presentations, go to https://www.seidengroup.com/presentations/.
Differences Between Zend Core and Zend Server on IBM i
/6 Comments/in IBM i, PHP, Web development /by Alan SeidenUPDATE: As of 2020, we recommend using Seiden PHP on IBM i and LINUX for reliability, speed, and ease of maintenance.
/usr/local/zend/apache2
* where php and php-cli reside
var/log
If the new HTTP port of 10088 seems hard to remember, you can change it to something that’s easier to work with, such as the standard HTTP port of 80. To do that, edit /www/zendsvr/conf/httpd.conf and change Listen *:10088 to Listen *:80 or whatever you want. (Of course, first ensure that no other service is running on that IP/Port combination.)