Scaling PHP

This two year old post about Rasmus Lerdorf’s PHP scaling tips (slides) is interesting in the context of what we’ve learned since then. APC now seems common, and it’s supposedly built-in to PHP6. Still, I’d be interested in seeing an update. Are MySQL prepared statements still slow?
And that’s where Rasmus’ latest presentation comes in. We [...]

Installing PHP APC On RHEL/CentOS

Yum up some packages:

yum install php-pear php-devel httpd-devel

Install APC using pear (the pear installer is smarter than the pecl installer):
When the installer asks about APXS, say ‘no’. 

pear install pecl/apc

Tell PHP to load APC:

echo extension=apc.so > /etc/php.d/apc.ini

Restart Apache:

/sbin/service httpd graceful

Mark Jaquith On WordPress Security For Plugin Developers

I’ve been pretty aware of the risks of SQL injection and am militant about keeping my database interactions clean. Mark Jaquith today reminded me about the need to make sure my browser output is filtered through clean_url(), sanitize_url(), and attribute_escape(). Furthermore, we all need to remember current_user_can(), check_admin_referer(), and nonces.

Is My PHP Script Running Out Of Memory?

I’ve got a PHP script that sometimes just dies with no errors to the browser and no messages in the error log. I’ve seen this in the past with scripts that consumed too much memory (yeah, it should have issued an error, but it didn’t, and increasing the memory limit fixed it), but now the [...]

Web Development Languages

David Cloutman pointed to Craiglist’s job ads as an indicator of programming language popularity. Here’s the hit counts for “web design jobs” and “internet engineering jobs” in the Bay Area:

 
PHP
Java
Ruby
Python
PERL

internet engineering jobs
167
246
85
98
109

web design jobs
110
71
22
19
31

Cloutman has a few ideas for what the numbers mean, but I’m just entertained by the data. (Note: he corrected his original [...]

JSON on RHEL & PHP 5.1.6

Stuck with PHP 5.1.6 on RHEL or even CentOS (and a sysadmin who insists on using packages)? Need JSON? I did. The solution is easy:
yum install php-devel
pecl install json
The pecl install failed when it hit an 8MB memory limit, and I was clueless about how to fix it until I learned that the pecl installer [...]

Parse HTML And Traverse DOM In PHP?

I spoke of this the other day, but now I’ve learned of PHP’s DOM functions, including loadHTML(). Use it in combination with simplexml_import_dom like this:

$dom = new domDocument;
$dom->loadHTML(’<ul><li>one</li><li>two</li><li>three<ul><li>sublist item</li></ul></li></ul>’);
if($dom){
$xml = simplexml_import_dom($dom);
print_r($xml);
}

This IBM developerWorks article has some more useful info.

Parse HTML And Traverse DOM In PHP?

I love how easily I can traverse an HTML document with jQuery, and I’d love to be able to do it in PHP. There are a few classes, but the PHP binding for Tidy seems to be where it’s at. The Zend dev pages make it look that way, anyway.

Apache, MySQL, and PHP on MacOS X

p0ps Harlow tweeted something about trying to get an AMP environment running on his Mac. Conversation followed, and eventually I sent along an email that look sorta like this:
If you’re running 10.4 (I doubt it, but it’s worth mentioning because I’m most familiar with it), here’s how I’ve setup dozens of machines for web development [...]

sifting results of error_log( …

sifting results of

error_log( $_SERVER[’REQUEST_URI’] ."\n". $_SERVER[’REMOTE_ADDR’] ."\n". print_r( debug_backtrace(), TRUE ) );