home

Archive for the 'PHP' Category

PHP mail() logging

Wednesday, January 17th, 2007

I’ve posted my php sendmail wrapper before, but I just noticed that Ilia Alshanetsky has written a php mail logging patch that essentially does the same thing, but from within PHP itself. This is nice because it can log the full path of the file and line where mail() was called, whereas my script can only log as much info as PHP passes to sendmail (which isn’t very much) and what it can get from the environment. The downside is since it’s a patch, it requires recompiling – my script can be dropped into any installation (PHP4/5, and maybe even 3) and just requires a simple php.ini change.

I should also point out that if you’re using this, you should be sure that you don’t “whitelist” localhost in your mail server, or otherwise people can just connect to your SMTP server locally, and send mail without requiring a username or password. If they use SMTP you can’t see what script or virtual host sent the mail either way, but at least if you require authentication you can see what account is being used if it becomes an issue.

CodeIgniter

Tuesday, April 18th, 2006

I’ve been playing with a sweet PHP framework called CodeIgniter, and I have to say: I love it. It uses the MVC pattern, which I’ve never much cared for, but does it in a nice way: by staying out of the way. The models are incredibly basic, and really, you don’t even need them. The views are PHP templates done the way PHP templates should be done; with PHP.

Something many frameworks miss: the documentation is amazing. There is a great tutorial video on their website, and after watching it, many people say they’re hooked. The user guide is even better: well laid out, and it even has a slick interface and look that makes it pleasurful to use. What’s missing is pure API documentation, but there is a reference (that I now have printed and posted just above my desk) and most of the calls are outlined in the manual.

Unlike many other frameworks, it doesn’t impose any strict methods of doing anything. You have a controller that is a class with a bunch of functions. There are ‘helpers’, ‘libraries’, ‘plugins’, that all have a common way of loading ( $this->load->library(‘session’); for example). These can be core libraries, or application-specific (installed in the application/ folder). The directory layout is very intuitive, and it can all go underneath an HTTP root folder (not requiring certain files inside/outside of a web-accessable folder — double plus for people using shared hosting with open_basedir restrictions).

I started experimenting with it for the second version of web interface I’m writing, and I actually decided to port another application I had 75% done to it. It’s still in-progress as I write some user authentication routines, and I decided to write a “SuperModel” class (yeah, kind of dumb name) that builds forms and validates them – because I hate manually building forms.

If you’re a PHP developer, I highly recommend checking this framework out. It’s only been around publically for a couple months and has been aparently downloaded over 5000 times, and has a growing and active community in the forums.

Zend Framework

Monday, March 6th, 2006

The much-anticipated Zend Framework was released a couple of days ago, and I finally got around to looking at it today. I really wasn’t impressed much.

It’s really not much more than PEAR, with a sloppy MVC framework tacked on. I certainly don’t think it’s not a useful library: the Zend_InputFilter class looks very handy, and the Zend_Db stuff is an interesting implementation (though, I’m not sure if I’ll be switching away from ADOdb anytime soon).
I’m still not currently using a formal MVC framework (I haven’t yet found one I really like – though I do implement something similar the view-controller part without object oriented code), and by the looks of things, I won’t be building any applications using just the Zend Framework, either.

Okay, so it’s written by the people behind PHP. Is this really the best benefit it has over any other framework? I certainly don’t seem to be alone in thinking this way.

Diag| Memory: Current usage: 26419 KB
Diag| Memory: Peak usage: 26538 KB