Nephtali

Oh! Nephtali!

Alright, so if you look up “Nephtali” on thinkbabynames.com, you see it listed as a variant of “Naftali.”

The boy’s name Naftali \n(a)-fta-li, naf-tali\ is of Hebrew origin, and its meaning is “struggling”. Biblical: a son of Jacob and one of the ancestors of the 12 tribes of Israel.

“Struggling.” Apt.

How many phone calls from Adam have I received in the last year that began, “With Nephtali, if you were to do [blah blah blah], which of these approaches would you like the best?”

Countless. Every other day is a conservative estimate, considering that many days, there were many phone calls.

The man has been obsessively working on this “Nephtali.” Yesterday, in our ritual Nephtali conversation, he said, “So old man, it’s time to post this to your blog.”

After so many versions and so much work on Adam’s part, it’s time to break the silence.

What is Nephtali?

Well, I’ll give you my take on it, but for the practical details (and a download), go to nephtaliproject.com.

Nephtali is a framework for the development of data-driven websites. It uses PHP 5 and is object-oriented. It’s flexible, extensible, and plays nicely with other frameworks, like the Pear and Zend frameworks. Because of how it handles data, developers will tend to write more secure Web apps. It separates the presentation from the programming logic well, so that it is easy to use a tool such as Dreamweaver without worrying about messing up the behind-the-scenes programming. And, the API was written with a continual drive to make it user-friendly for programmers, while maintaining a value on security.

My experience with Nephtali, thus far

I’ve played with a couple iterations of Nephtali, and once getting oriented, I found I like it. (Granted, I’m biased having had so many discussions with Adam about it.)

Compared to CakePHP, Nephtali is easier to use. For instance, in CakePHP, or other Model-View-Controller frameworks (e.g., Ruby on Rails), database models are abstracted and then calls in the app rely on those abstractions. While there is a great benefit to this, I’ve found the abstractions themselves to be problematic. Nephtali can provide abstraction to fairly simple database actions (standard CRUD operations), but, gosh darn it, I like being able to jump in and write SQL. The reality for me as a developer is that database model abstraction causes me more grief than they are worth. Abstraction can slow me down, especially when the queries and relationships get tricky. Now, one of the big benefits to abstraction is that it can promote the DRY principle. Nephtali provides well for that, through implementing sub-classes, and I still have the direct, easy line to thinking about and working with the data in SQL.

The future of Nephtali

I could go on, but the proof for Nephtali will be in how many sites it is eventually used on, and how many other developers get their heads into it.

So, developers, check out Nephtali. And if you have questions or suggestions, do not hesitate to dialogue with Adam about it. And tell him to post a screen-cast of building a basic app with Nephtali.

For now, I’m going to see if I can get Adam to smash a bottle of champagne over his development box in honor of this release. Congrats, Adam!

Trouble with PHP5 and SQLite 3

After fiddling for a while with SQLite 3 and PHP 5.0.4 on the Mac PowerBook (OS 10.4.2) I’ve been using, I just saw that the current version of PHP does not include support for SQLite 3. Only for version 2. Dangit.

I don’t think I’m going to bother installing SQLite 2 just so it can work with PHP. Hopefully a new version of PHP will be released that includes the support.

I have PHP and SQLite working fine on a Windows XP system at MSU, so I’ll just use that for now. I’m just looking into it to learn it at this point.

PHP tab navigation switcher

I don’t consider myself a web programmer, but I have occasionally fiddled with the odd perl script, php, or asp code snippets. I had a situation yesterday that caused me to want to come up with a php script that would switch tab graphics on a web site, based on the URL of the page.

I’m building the site with Dreamweaver, and my client is going to use Contribute to maintain it. So, I have a page template for the majority of the pages in the site. The navigation is a set of horizontal tabs, and if you are in a certain section of the site, the navigation tabs should indicate that you are in that section.

Unfortunately, this might have meant creating a separate template file for each section of the web site. I thought about this for a few moments, visualizing the nightmare of updates this might create, and decided to try mashing together a script that would solve my problems.

I started by looking through the URL parser in a file I use on my site to create breadcrumb navigation based on the directory. Once I had that piece nailed down, I simply assigned a variable with the part of the URL in question, and then did a series of if else statements to determine which navigation tab html code to include.

So, the pieces:

  1. navswitcher.php — this determines which html navigation file to include based on the part of the URL immediately following the domain name
  2. a separate html file containing just the code needed for the navigation tabs; one file per section
  3. the php include line to add to the Dreamweaver template file where the navigation is supposed to be

Here is the navswitcher code:

// retrieve and parse the web address after the domain name
$str = $PHP_SELF;

ereg("^(.+)/.+\\..+$", $str, $part);
$str = $part[1];
$str = substr($str, 1);

// for the first example, the URL might be http://domain.com/client/joe.php
// this script grabs the "client" part and makes it the value of $str

// set directory name variables
$navfiles = "/path/to/html/nav/files";

$client 	= 	"client";
$services 	= 	"services";
$portfolio 	= 	"portfolio";

// set up cases where $str will match certain values and output different files
if ($str == $client)
include("$navfiles/main_client.txt");

elseif ($str == $services)
include("$navfiles/main_services.txt");

elseif ($str == $portfolio)
include("$navfiles/main_portfolio.txt");

// if none of those, then it must need the default home navigation
else include("$navfiles/main_home.txt");

That code should go into its own file which would then be included in the Dreamweaver template (or from whichever file you need it in).

Doing it this way enabled the site to work from a single Dreamweaver template file, instead of one for each section of the site.

This solution also separates the navigation html itself from the scripting that puts it in place. This means that my client will be able to edit those individual files when they need changing, rather than have to mess around with all the PHP code or Dreamweaver templates (which would require that he own Dreamweaver).