PHP
After my upgrade from Fedora to CentOS I noticed a few issues with the PHP photo gallery I use (Scry). Specifically, Scry wasn’t generating thumbnail images. A quick check of /var/log/httpd/error_log showed the following error…
PHP Fatal error: Call to undefined function: imagecreatetruecolor()
It turns out that there’s a slight packaging difference between Fedora and CentOS (and presumably Redhat Enterprise as well). CentOS uses a separate php-gd package for the GD image library, and the php-gd package hadn’t been installed. This fixed the problem for me…
yum install php-gd
service httpd restart
For quite a while now I’ve taken advantage of the fact that you can search php.net just by adding whatever you want to search for onto the end of the URL (e.g. http://au.php.net/array_keys). In fact whenever I’m working with PHP I usually have a tab open to php.net just for this purpose.
Generally this works reasonably well, but occasionally you close your tab or mistype something and its a bit messy. I use the links toolbar in Firefox heavily, and the bookmarklets that I’ve got for MT and FoF are really useful. So I sat down and created a bookmarklet to do a search of PHP.net. Drag this link onto your links toolbar. Then whenever you click on it you’ll be prompted for a search term, and then it’ll build the appropriate URL and take you straight there.
The little bit of javascript is as follows:
javascript:top.location ='http://au.php.net/'+prompt('Search PHP.net for:');
You might want to change the “au.php.net” to point to your local mirror, but otherwise it works well. I haven’t teasted it in IE, but it should work.
Chris Shifflet has started writing a new collumn for PHP Magazine called “Guru Speaks”. In his first column he ovvers some excellent advice on avoiding Page has Expired messages.
The warning is a result of the user utilizing the browser’s history mechanism to access a previously viewed page, usually by clicking the back button or refreshing. One cause of the warning is that the page has expired from the browser’s cache, so it wants to inform the user that it must request the page again, just in case this is not something the user wants.
Chris also wrote the SSL tutorial that I’ve linked to before. He’s one of those writers who seem to be able to take a complex topic and explain it easily. Well worth the read.
One organisation I was involved with used MyHelpdesk as its primary helpdesk database. With a few mods, it worked very well.
This morning I stumbled across a release announcement for OpenIT, a package claiming to be:
PHP driven Inventory, HelpDesk, Support, Issue Tracking, and Knowledge Base web application. Focuses on simplicity and ease of customization.
Sounds like a package to keep an eye on!
Of course now that I have a functioning news aggregator again, I’ve got a few useful bits and pieces to point to! Devshed has another useful article on Best PHP Practices.
So I thought it would be useful to everyone to know what I consider to be the best practices while developing PHP. There are many PHP editors out there; trust me I’ve used just about all of them, from full blown “what you see is what you get� editors, all the way to those that are a Windows notepad clone. So I plan on filtering out the best from the worst. On top of that I’m going to be telling you all about the best programs for working with HTML and MySQL
The author advoctes using a few different tools and a bit of planning to make your PHP coding much easier.
When designing (especially database design) any app of a significant size, one thing that I’ve found over the years is that I can’t do it on a computer. I find I need to have the whole thing in front of me where my eyes can roam across the entire design and see whats missing. I use either a large artists sketch pad or a whiteboard for the job, and they work well for me.
The other thing which is essential is to have some sort of specification document. This doesn’t need to be anything elaborate, but it has to list all of the key functions and features required. When knee deep in coding an application its easy to miss or forget some features, so a specification can serve as an important memory aid!
Devshed has an article on Developing an Object Oriented Credit Card Transaction Processor.
This article will walk readers through the process of outlining a flexible Object Oriented design that will facilitate adding Merchant Services and Payment Methods in the future without affecting the client code.
Looks like a useful exercise in good design and development.
While I’m talking about my change of RSS reader, I really should link to Magpie RSS a PHP RSS Parser. Magpie RSS looks really nice, and could be handy for other projects I have in mind.
MagpieRSS provides an XML-based (expat) RSS parser in PHP.
MagpieRSS is compatible with RSS 0.9 through RSS 1.0. Also parses RSS 1.0’s modules, RSS 2.0, and Atom. (with a few exceptions)
Chris Shiflett has posted an excellent article on improving the security of PHP sessions, in order to prevent Session Fixation or Session Hijacking attacks.
It is a common misconception that PHP provides a certain level of security with its native session management features. On the contrary, PHP simply provides a convenient mechanism. It is up to the developer to provide the complete solution, and as you will see, there is no one solution that is best for everyone.
Really useful stuff!
OnLamp has an excellent the PEAR documentation, and this Getting Started Guide from Keith Edmunds.
All in all, an excellent library, hightly recommended.
In Do You PHP?, Rasmus Lerdorf talks about the history and evolution of PHP, and addresses some criticisms of the language.
Use the right tool for the job. I have run across companies that have completely bought into PHP, deploying it absolutely everywhere, but it was never meant to be a general-purpose language appropriate for every problem. It is most at home as the front-end scripting language for the Web. Depending on the traffic the Web site gets, it can be used to do the bulk of the back-end work as well.
Rasmus covers some of the same ground in this article as he does in his PHP Tips and Tricks presentation, but it makes excellent reading whether you’ve seen the presentation or not.