-
Optimizing Zend Studio on Mac OS X Dec 13, 2005
Recently, I purchased a Mac mini and started using it as my home computer. Overall, it is a pretty nice little machine but its 1.42 GHz G4 processor isn’t the fastest thing out there. On some larger applications, such as Zend Studio, it is a little sluggish. Fortunately, there are two things that you can do with Zend Studio to get an immediate performance increase.
First and easiest, select
Tools > Preferences > Code Completion
from the menu bar, and findAutomatically Show Code Completion List
. IncreasePopup after ____ ms
to 500 ms and the text editor will immediately become more responsive.Second, you can try increasing Studio’s memory footprint if you have enough RAM. Using the Finder, navigate to the folder
/Applications/Zend/ZendStudioClient-5.0.0/bin
, and then control-click (right-click) onZDE
and selectShow Package Contents
from the context menu. Double-click onContents/Info.plist
to open it in the Property List Editor. UnderRoot > Java > VMOptions
, change the string to specify the minimum and maximum size of memory to use. I have 1 GB RAM, so I use-Xms128m -Xmx512m
to specify a minimum of 128 MB and a maximum of 512 MB. Save your changes and then restart Studio. You’ll need to play around with the setting to see how it affects performance. Your results will vary based on how much physical RAM is installed in your machine. This tip is also useful for other Java applications, such as Eclipse.It’s worth noting that you can do both of these tweaks on all platforms supported by Studio. On platforms other than Mac OS X, the memory settings are command line switches to Java in the shortcut or script that starts Studio.
After making these two changes, I have found the Studio’s performance on the Mac mini to be very acceptable. Powerbook users (also with the G4 processor) should benefit from them as well.
-
Zend Framework Webcast Recording Dec 5, 2005
As part of our effort to keep the community informed about the status of the Zend Framework project, Andi and I presented the first of what will hopefully be a series of webcasts.
The webcast was hosted by php|architect, and they have just posted a new page with a recording of the event for those who might have missed it:
Zend Framework Webcast Recording
This first presentation includes introductory material on the key concepts behind the framework, its architecture and development methodologies, and some use cases demonstrating components that we have developed.
-
Namespace Operator Nov 29, 2005
If you have been trying to follow the countless threads on the php-internals mailing list regarding a new operator for namespaces, my script below will definitely save you time.
// generate a new namespace operator suggestion function namespaceOperator() { return chr(rand(33,47)) . chr(rand(33,47)) ; } // predict next ten suggestions to php-internals for ($i=0; $i<10; $i++) { echo namespaceOperator() . "\n"; }
-
Zend PHP Conference Oct 13, 2005
There is definitely some excitement in the air now that the Zend PHP Conference is less than a week away (Oct. 18th – 21st). I’m happy to say that I’ll be attending the conference, along with the rest of the US-based Zend staff, and I am greatly looking forward to it. There are a host of interesting talks promoting PHP use in the enterprise, from both business leaders and tech luminaries.
On the business front, Zend has somehow managed to corral an impressive lineup of industry leaders, all anxious to pump PHP for business. Among them are Marc Andreessen of Netscape fame, Ken Jacobs from Oracle, Rod A. Smith from IBM, and Adam Bosworth from Google.
For developers, this promises to have one of the best tech lineups of any recent conference, with many PHP core team members presenting. Among the talks I hope to attend are Unicode support in PHP 6, PDO: PHP Data Objects, Service Data Objects for PHP, and Oracle and PHP.
Before we start bouncing between all of these great talks, Matthew Weier O’Phinney and I will be giving a tutorial session on Setting up PHP.
If you haven’t signed up for the conference yet, there’s still time to register!
Update: Slides (PDF) from the session are now available.
-
Zend Studio Remote Debugging Sep 11, 2005
Remote debugging is one of the most powerful features of Zend Studio, whether used with a webserver on your local machine for development or to profile and troubleshoot a production server.
To use the remote debugging and profiling features of Studio, the webserver must have the Zend Studio Server component installed. This is a special PHP extension that interfaces with the Zend Engine to provide powerful debugging and inspection capabilities, and provides the socket-based communication back to the Studio client for remote control.
While the debugger is so powerful that it might seem almost magical at first, the mechanics of its operation are very straightforward. When a URL is selected for debug in the Studio client, it activates your web browser and directs it to load the specified URL, with a special set of GET request variables tacked on the end that cause the Studio Server extension to spring into action. When the page loads, the extension opens a connection back to the Studio client on the debug port. Once the two-way communciation is established, the browser hangs in page-load limbo while the debugging commences.
Studio knows how to open your browser by the “Browser Activation Command”, and changing this can be useful. This option can be found on the “Preferences” dialog, accessible from “Tools” on the menu bar. On Windows, the Studio will be preconfigured to use Internet Explorer, so its default will be “
\Program Files\Internet Explorer\iexplore.exe
“. If you’d like to have it open Firefox instead, change the activation command to “\Program Files\Mozilla Firefox\firefox.exe
“. The browser activation command is also used when the “Show In Browser” option is invoked from the context menu by right-clicking on the Debug Output pane.On UNIX-like operating systems, the default browser activation command will be “
mozilla
“, a shell script that loads the browser. This can sometimes be a headache for users who do not have this script or the script cannot be found because it is not in the environmentPATH
. If Studio is having trouble activating your browser, drop to a shell and troubleshoot by trying to enter the same command manually. Once you are able to run it from any arbitrary directory on the shell, Studio should have no trouble activating it.There are two small drawbacks that become apparent when using the debugger or profiler on a regular basis. First, it takes a noticeable amount of time to open the browser window with your debug URL, and you must wait on your browser during this time for each page that you debug. Second, depending on your browser, Studio may open a new browser window each time the debugger or profiler is invoked. It’s very easy to find yourself with a pile of useless browser windows open, especially after repeatedly running the profiler. However, this isn’t a drawback in Studio itself, it’s just the browser’s behavior.
On both Windows and UNIX-like systems, there is a handy trick that eliminates both the startup latency and the extraneous browser windows. You can set your browser activation command to run cURL instead of your browser. On Windows, download the cURL binaries and place them somewhere like “
\curl
“. Next, change the activation command to “\curl\curl.exe
“. Now, Studio will use cURL whenever the debugger or profiler is invoked. Compared to launching the brower, cURL will appear instantaneous, and it will also not open any additional windows. You can now profile as many times as you’d like without ever leaving Studio or closing extra windows. The only downside of this trick is that the “Show In Browser” option will no longer launch the browser, however you can easily change the browser activation command back at any time if you need this capability. -
Upgrading Zend Studio’s Internal Debugger Jul 13, 2005
Zend Studio for Windows ships with an “internal” debugger for running your scripts in Studio without a webserver. Studio 4.0.2 ships with PHP 5.0.3. Recently, I encountered a bug in 5.0.3 that was corrected in 5.0.4 and I wanted to upgrade the internal debugger myself rather than wait for the next Studio release. Here’s how to do it.
First, download the ZIP package of Windows binaries from PHP downloads. Extract the files
php-cgi.exe
andphp5ts.dll
to a temporary folder. Rename the filephp-cgi.exe
tophp.exe
. This is necessary because Studio needs the CGI version of PHP, and the ZIP package’sphp.exe
is the CLI version.Next, find Zend Studio’s internal PHP5 interpreter. This is the default installation path:
C:\Program Files\Zend\ZendStudioClient-4.0.2\bin\php5
Notice two files in this directory:
php.exe
andphp5ts.dll
. Backup these two files and then remove them from the directory. Finally, replace these with the versions from your temporary folder, and the upgrade is complete. You can write a simple script withphpinfo();
inside Studio to verify the upgrade. -
PHP and VISA Jul 4, 2005
For a short time now, I have been interested in hooking up PHP with VISA (Virtual Instrument Software Architecture) to allow Windows users of PHP to control any I/O that is supported by the VISA standard. This includes serial, GPIB, VXI, PXI, USB, and other interfaces. I think that PHP would be a very good language for test automation in general because of its easy syntax and large number of convenience functions for string handling and other tasks common to instrument control.
I thought that I had a made a significant discovery when I learned about VISA-COM, a set of COM interfaces to VISA. Accessing VISA through COM in PHP would be very convenient. I spent some time looking at NI-VISA‘s implementation of VISA-COM and also talking to the folks over at National Instruments. Unfortunately, the VISA-COM interfaces are not based on IDispatch so they cannot be used late-bound from scripting environments. Code written in VBScript to use VISA-COM will not work, however that same code will indeed work in Visual Basic 6.0. PHP 5 will also not be able to make use of VISA-COM.
With VISA-COM out of the picture, that leaves two options. The FFI extension in PECL replaces the old W32API extension for PHP 4 and provides a “Foreign Function Interface” for PHP5 to access external libraries. FFI development seems slow and its present state may not have all of the functionality required to control the VISA DLL. However, it’s definitely worth some experimentation. The other option, which is perhaps the most desirable, is to create PHP bindings for VISA as a PHP extension.
-
Zend Certified Engineer May 31, 2005
Well, I finally found some time to get down to the testing center to take the Zend PHP Certification, and I passed.
I am now a Zend Certified Engineer.
-
Controlling iTunes from PHP 5 May 30, 2005
If you are running PHP 5 on Windows, there is support for COM interfaces built right into the PHP core. The COM support in PHP 5 allows you to automate all kinds of software that expose COM interfaces, such as Microsoft Office. Everyone’s favorite music player, iTunes, also exposes a very nice set of COM interfaces that are easily controlled from PHP 5.
To get started, instantiate a new COM client to iTunes. If iTunes is not currently running, it will be opened automatically.
// Instantiate a new COM client to iTunes $iTunes = new COM('iTunes.Application');
This creates an object
$iTunes
which is a client to theIiTunes
interface, the top-level interface to the iTunes application. From here you can directly access a number of useful methods and properties for controlling iTunes, or you can access the other interfaces that it provides.// Easy Controls $iTunes->Play(); $iTunes->Pause(); $iTunes->Stop(); $iTunes->PreviousTrack(); $iTunes->NextTrack(); $iTunes->SoundVolume = 50;
To monitor what’s currently playing in iTunes, you can use the
CurrentTrack
property ofIiTunes
to return anIITrack
.// What's playing now? $currentTrack = $iTunes->CurrentTrack; $trackName = $currentTrack->Name; $trackNumber = $currentTrack->TrackNumber; $albumName = $currentTrack->Album; $artistName = $currentTrack->Artist;
While the capitalization of the methods and properties isn’t the normal way for PHP objects, I’d recommend doing it this way to stay consistent with the naming conventions of the iTunes COM classes. They are actually not case sensitive.
These examples only scratch the surface of what you can do with the iTunes interfaces. To learn more about controlling iTunes with COM, you can get the complete iTunes SDK from Apple which includes documentation in CHM (Windows Help) format.
Note: While these examples look like they should work on PHP 4, they consistently caused my PHP 4.3.10 interpreter to crash. COM support was completely rewritten for PHP 5 and all of the examples here were tested under the CLI version of PHP 5.0.3 without any problems. Please note that these examples will most likely not run under a webserver.
-
PEAR XML_RPC Bug #4231 Apr 27, 2005
Today I submitted Bug #4231 to PEAR. An expanded version of my bug report can be found on this website.
One thing that using Python’s bundled xmlrpclib on the Python interactive shell has taught me is that it’s very easy to make RPC method calls with bad parameters. Using a server built on PEAR’s
XML_RPC_Server
, calling a method with a bad parameter count will cause PHP undefined variable notices to be prepended to the return payload if notices have not been disabled.This is a security issue because the notices reveal the script path to the client. Also, this makes troubleshooting RPC calls somewhat difficult because although the server’s XML response remains intact, most clients I have tried will report a parse error when the PHP notices are encountered. This is true of the clients in PEAR’s
XML_RPC
, Python’sxmlrpclib
, and CPAN’sXMLRPC::Lite
for Perl.Update 9-May-2005: This bug has now been fixed in the CVS, although it took a little work to get there including an addendum to my original report. While this problem has now been corrected, you may still find the examples in the addendum helpful if you’re interested in getting a little extra out of the dispatch map through multiple signatures for an RPC method.