On my recent upgrade of php to 5.3, gentoo created a new slot so that people could run 5 and 5.3 in parallel. Gentoo is always giving you options (can you handle it? “ask yourself, do you feel lucky, punk?”). As usual, you must proceed with caution. And as usual, you will probably learn something along the way. This time around, the lesson is on php.ini defaults. (continued…)

I have been so happy with my gentoo boxes lately, having had zero problems for the past few months, and no itch to bump. I must have lucked out and hit a really stable spot in the ever-changing world of open source.

But I don’t want to get too comfortable. Much longer and I probably won’t have a clean upgrade path. Besides, I think I smell something shiny out there somewhere… Seriously, I am looking forward to the latest XBMC changes. That software absolutely rocks.

Here we go! (continued…)

This toolkit was written by a guy down the road over in Chapel Hill, it seems. The idea seems to be to generate and configure MVC-structured PHP code with RESTful web access. Supports multiple apps with one installation. Works for me.

I grabbed the 0.20 release. It comes with a web-based front end that will mock up your initial application code. Unfortunately the javascript wasn’t working and it looked like it had a bad path to the embedded jquery library. Rather than kill myself researching, I switched to the git “edge” branch:

cd development/git
git clone http://github.com/recess/recess.git
  Initialized empty Git repository in /home/m/development/git/recess/.git/
git checkout master 
  Already on 'master'

Now it seems to be able to find its css and javascript.

Next problem was with mod_rewrite. It just wouldn’t work. Time to troubleshoot… and fixed. In Recess’ defense, this was probably the reason the 0.20 release didn’t work well.

Next, I went to create an app. I had to change the permissions on the apps directory, as instructed, since I unzipped recess under a group for which apache did not have write access.

Next, I cranked through a model for one of my apps. WOW, now I have a full set of “routes”, URL’s with which to RESTfully access my model. This is looking nice… to be continued…

mod_rewrite is essential if you’re going to write RESTful web services. Here are the steps I went through to troubleshoot my installation:

  1. Ensure you included mod_rewrite in your apache installation. For gentoo, you can use [eix www-servers/apache] – Gentoo’s apache2_modules_rewrite flag is enabled for apache, looks good.
  2. Test to see if it is being loaded. I created a dummy page phpinfo.php with the contents [<?php phpinfo(); ?>], to see what PHP had to say about it. Search for mod_rewrite – yep, there it is, good. If not, make sure it’s loaded in httpd.conf, the load line may be commented out.
  3. Now make sure it’s enabled for the path you’re using. The apache directive is [RewriteEngine On], and it has to be somewhere in your httpd.conf or an included file. In my case I use virtual hosts. According to Apache docs, I needed to add both of these to the top level of my virtual host directive:
    RewriteEngine On
    RewriteOptions Inherit
  4. The mod_rewrite rules I’m dealing with are all in .htaccess files. In that case you have to make sure you’ve turned on the switch that allows .htaccess files to override your settings. Basically, you’ll need [AllowOverride All] enabled for the path where you want to use .htaccess files.
  5. Finally, make sure your .htaccess settings and rules look good. Here’s an example I pulled from another good troubleshooting blog entry:
    cat .htaccess
     Options +FollowSymLinks
     RewriteEngine On
     RewriteRule ^alice.html$ bob.html
     RewriteRule ^bob.html$ alice.html

    It should force bob’s page to load when you request alice’s, and vice versa. Nice simple little test.

Once I went through this list, I was good to go.

From the “why-do-I-need-Perl-any-more” department…

PHP now provides perl-like regex functions, and writing websites has never been so much fun! I have always loved Perl for text parsing of any kind, and I realize that was because of its powerful regex functionality. During some recent PHP contract work for my friend John, I discovered that PHP’s got perl regex, via this…

preg_match( $perl_style_regex, $source, $match_result_array ).

I can scrape like a madman now. Happy happy joy joy. Anyone who disparages PHP has either never used it or has been trained in the pretentious ways of the Java prima donna. (JUST KIDDIN’ yall!) 😛