Most insane use of PHP to date

One of the other developers for IntraHealth has been abusing PHP in every way possible. This time Carl may have gone too far. We’re putting together a “shelf-top” appliance for installations of iHRIS that don’t have a server room to rack-mount equipment. As much as possible, we want to make it easy to plug the box into your network and go with as little fiddling as possible. To that end, I found the Mini-Box M200 with an LCD panel that we could set up with a simple menuing and configuration system. In all the other projects we’ve been working on, we’ve used PHP because of, among other things, the low barrier to entry it offers compared to, say, Java. PHP has been irritating at times, but I think it may be worth it if it means that we can get more people involved in the client countries. When I first saw the LCD panel, my thought was “You know, it’d be nice to have an ncurses front-end for that thing.” Then you could test in terminal window and deploy it without changing your code. Carl had the same thought. So he began hacking out an ncurses-based menu system for the LCD display. And it’s written in PHP. I don’t think I’m going too far out on a limb here to say that this is the first PHP code designed to be used through an LCD panel. This only confirms my suspicion that Carl is a genius, of the evil, insane variety.

Ubuntu Packages and PHP

(Hello, Planet Ubuntu Users!  I’m looking for a second MOTU on my php-xdebug package as well as someone to revu my libapache-test-perl package.  Any takers?) Emacs CVS now includes XFT (i.e. smooth fonts) in the main branch, so I’m discontinuing my old emacs-xft-snapshot build.  Still, the other emacs-snapshot package is targeted to Debian and I’m running Ubuntu Gutsy.  So I’ve uploaded a snapshot build to my PPA on Launchpad. One thing that I included is flymake support for PHPCarl asked me earlier today if I knew how to get the compilation mode in Emacs to work with PHP’s lint function to find highlight problems.  I said flymake would be better, but didn’t know how to do that right off, either. After a bit of twiddling, I figured it out and, as a bonus, got compilation mode figured out, too. If you want to enable flymake for PHP-mode (yes, I have a Debian package for that, too) in a version of Emacs you already have installed, add the following code to your .emacs file:

;; Flymake PHP Extension (require 'flymake) (unless (fboundp 'flymake-php-init)   (defun flymake-php-init ()     (let* ((temp-file (flymake-init-create-temp-buffer-copy                        'flymake-create-temp-inplace))            (local-file (file-relative-name                         temp-file                         (file-name-directory buffer-file-name))))       (list "php" (list "-f" local-file "-l"))))) (let ((php-ext-re "\\.php[345]?\\'")       (php-error-re        "\\(?:Parse\\|Fatal\\) error: \\(.*\\) in \\(.*\\) on line \\([0-9]+\\)"))   (unless (assoc php-ext-re flymake-allowed-file-name-masks)     (add-to-list 'flymake-allowed-file-name-masks                  (list php-ext-re                    'flymake-php-init                    'flymake-simple-cleanup                    'flymake-get-real-file-name))     (add-to-list 'compilation-error-regexp-alist-alist                  (list 'compilation-php                    php-error-re  2 3 nil nil))     (add-to-list 'compilation-error-regexp-alist 'compilation-php)     (add-to-list 'flymake-err-line-patterns                  (list php-error-re 2 3 nil 1))))

Now, whether you’re using the emacs you started with or the latest emacs-snapshot, you need to tell emacs to use flymake on PHP files.  Add:

(add-hook 'php-mode-hook (lambda () (flymake-mode t)))

to your .emacs file and you’re good to go.

Ubuntu Emacs + misc.

I have been having a lot of fun with my Launchpad PPA. In addition to org-mode, I’ve packaged color-theme and a snapshot of the Unicode+XFT branch of Emacs using the package name emacs-xft-snapshot so it doesn’t conflict with existing packages. I also put a package for PHP’s Xdebug (which does a decent job of profiling PHP code and can be used to make pretty call graphs) and one for eMusic/J.