PHP
Zend Studio for Eclipse Drupal formatter
For years I've been a paying customer of Zend, using their Zend Studio Professional. They discontinued production of their custom Java version and opted to switch to making plugins for Eclipse.
I'm just now switching from the old Zend to the new one and discovered a formatter to handle all the code spacing automatically. Naturally, since I do most of my work with Drupal, I made a custom formatter file to follow coding standards for 4.7.x to 6.x. There have been some standards changes to take effect for D7, and I'm not coding for that yet, so this should be a good file for a general audience.
In your Zend for Eclipse, go to the preferences, PHP section, Formatter and Import... the attached XML file.
Don't forget to also run your code through the coder module, which will not only check your coding style, but look for upgrades, database injections, and some other cool things.
To my knowledge, PDT 2.0 doesn't have a formatter interface like Zend Studio 6 has. However, it does have another feature I insist on, removal of trailing whitespace.
Preferences - PHP - Editor - Save Actions - Remove trailing whitespace
Dries makes Views a priority
Dries Buytaert, Supreme Drupal Overlord, said today on the development@ mailing list the following:
As indicated earlier, I'm _all_ for incorporating more of CCK and Views into core. Let's make a concentrated effort for that in D7. It doesn't mean that _all_ of CCK/Views needs to be in core, but certainly the stable and critical parts should, IMO.
Barry Jaspan gets the credit for making the proper comments to receive such a reply.
Custom MAMP on Mac OS 10.5 Leopard
I wasn't able to get xdebug or Zend Debugger to work on my install of Mac OS 10.5 Leopard after trying the XTools version of PHP5 that now comes with the operating system, so I broke down and compiled PHP5 from scratch thinking it would make life easier in the end and finally get support for an mcrypt project I have on the todo list. I suspect it has to do with Leopard introducing 64 bit XTools software whereas xdebug and Zend Debugger were compiled for a 32 bit environment.
First, you should install XTools from the Leopard DVD and this installation process will just replace the Apache and PHP5 files that XTools installs and leave all the other configuration needed to get it to work in place.
The problem was when I loaded Apache, I couldn't connect. Console told me
httpd: Syntax error on line 114 of /private/etc/apache2/httpd.conf: Cannot load /usr/libexec/apache2/libphp5.so into server: dlopen(/usr/libexec/apache2/libphp5.so, 10): no suitable image found. Did find:\n\t/usr/libexec/apache2/libphp5.so: mach-o, but wrong architecture
Apparently this is because the custom compile I did is 32 bit and the new pre-packaged Apache is 64 bit, so I recompiled Apache, too.
./configure --enable-layout=Darwin --enable-mods-shared=all
make
sudo make install I grabbed a source snapshot of PHP 5.2.6 from php.net. This configure line made a successful compile of PHP 5.2.6 with various extensions for linking to MySQL 5.1.22.
./configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-apxs2=/usr/sbin/apxs --enable-cli --with-zlib-dir=/usr --enable-mbstring --enable-mbregex --enable-sockets --with-curl=/usr --with-config-file-path=/etc --sysconfdir=/private/etc --with-mysql-sock=/tmp/mysqld.sock --with-pear=/Library/PHP --without-iconv --without-openssl --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-mysql=/usr/local/mysql/bin/mysql_config --with-mcrypt --with-xmlrpc --with-bz2 --with-curl --with-zlib-dir=/usr --with-jpeg-dir=/usr/local/lib --with-png-dir=/usr/X11R6 --with-freetype-dir=/usr/X11R6 --with-xpm-dir=/usr/X11R6 --with-gd --with-pgsql
make
sudo make installThe MySQL config comes from installing the MySQL 5.1.22 official binaries to /usr/local/mysql.
Of course later, I realized Drupal 6 status page complains if GD isn't installed, so I found http://www.veola.net/macintosh/adding-gd-library-for-mac-os-x-leopard which even has the instructions on making GD a PHP extension so I didn't have to recompile all of PHP5. I used a more updated version of libpng because the one in the instructions didn't compile.
PHP developer interview questions
Even if the interviewer doesn't know the answers to these questions, they could probably get a good idea for a job candidate's comfort with the material from how much they stutter and squirm after each question.
General
- What are the current versions of Apache, PHP, and MySQL?
- What is a cookie and how is it useful?
- If you run into a problem while coding, what steps do you take to find the answer?
- What files are commonly found in these standard UNIX directories?
- /bin
- /boot
- /dev
- /etc
- /home
- /mnt
- /tmp
- /var
Custom CiviCRM 1.4 import script
This script was to import contact and payment data for a client. The $n and $p variables have the column names for the CSV files the data comes from. To protect the client, the contact and payment files arn't included. The sort script is intended to remove duplicate contact information, then import second, from the command line.
