Archive for the 'Web Development' Category

Page 2 of 5

I’ve detailed this problem before but yet again I’ve encountered the infamous iconv compile error. This bug is not new yet it still has not been fixed in the latest PHP release.

When compiling a custom version of PHP with libraries such as libxml and iconv the

make

process results in a linking error relating to the iconv library. The problem arises because I have two versions of iconv installed – the macports version in addition to the standard installation. A linking conflict arises and to eliminate the error a linking search order change (which is detailed in my previous blog post) must be made. In addition to the makefile modification, the previous workaround for the bug also included using

--with-iconv=shared,/opt/local

instead of the standard

--with-iconv

. Either the latest PHP (5.2.11) or OS X update has caused that workaround not to function correctly, now only

--with-iconv=/opt/local

should be used.

I’ve posted a script that I’m now using to keep my PHP installation up to date.

Average Rating: 5 out of 5 based on 205 user reviews.

So far my experience with NetSuite has been less than favorable. Their developer resources aren’t bad, but they aren’t terribly good either. I’m working on a project that involves searching through contacts & selectively modifying contact data based on search results. In some cases the search will return an empty result set – just like any normal search should. I would have thought that the PHP developer kit was mature enough to handle an empty search set, but apparently not. With the most recent “v2009.2″ framework I receive the following error when attempting to perform a basic

ContactSearchBasic

:

PHPtoolkit.php [416]:

Undefined property: stdClass::$pageSize

I’m guessing that most of their third party developers are using .NET or Java which would explain this extreme oversight in the PHP framework. Heck, it might be resulting from some obscure PHP compilation configuration option on my local machine (although I’m doubtful that it is). For those are experiencing the same issue I’ve uploaded a patch which fixes the issue in your PHPToolkit.php file.

Average Rating: 4.4 out of 5 based on 286 user reviews.

I’ve already posted some notes about compiling PHP 5.2 on OS X 10.5, but I came across a couple more issues today as I recompiled the binary with soap support. After searching around a bit I finally remembered that I needed to manually edit the make file in order to get PHP compiling correctly, I found the edit that needed to be made here. I’m reposting it here for my own future use:

Replace:

$(CC) $(MH_BUNDLE_FLAGS) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(PHP_GLOBAL_OBJS:.lo=.o) $(PHP_SAPI_OBJS:.lo=.o) $(PHP_FRAMEWORKS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) -o $@ && cp $@ libs/libphp$(PHP_MAJOR_VERSION).so

With this:

$(CC) $(CFLAGS_CLEAN) $(EXTRA_CFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(PHP_GLOBAL_OBJS:.lo=.o) $(PHP_SAPI_OBJS:.lo=.o) $(PHP_FRAMEWORKS) $(EXTRA_LIBS) $(ZEND_EXTRA_LIBS) $(MH_BUNDLE_FLAGS) -o $@ && cp $@ libs/libphp$(PHP_MAJOR_VERSION).so

Note the separation of the command into three separate lines, with the 2nd line having one tab character at the beginning of the string.

And here is my updated configure string command (with soap and iconv):

./configure --prefix=/usr --sysconfdir=/private/etc --with-libxml-dir=/opt/local --with-icu-dir=/opt/local --with-iconv=shared,/opt/local --enable-intl --with-config-file-path=/etc --mandir=/usr/share/man --infodir=/usr/share/info --with-apxs2=/usr/sbin/apxs --with-zlib-dir=/usr --with-mysql-sock=/var/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-dblib=/opt/local --with-mysql=/usr/local/mysql --with-pear --with-pdo-mysql=/usr/local/mysql/bin/mysql_config --enable-sockets --enable-exif --enable-wddx --enable-ftp --enable-cli --enable-mbstring --enable-mbregex --enable-sockets --with-curl --with-sqlite --enable-soap --with-libxml-dir=/usr

Another interesting note about PHP 5 is that compiling it with the readline extension (using

--with-readline

or

--with-libedit

) allows it to be a interactive scripting environment (a PHP console of sorts) just like python, ruby, or bash. Just run it from the command line with the -a option (info thanks to madmac).

Average Rating: 4.4 out of 5 based on 292 user reviews.

I use a combination of Trac and Subversion to manage my software development projects. Although new projects like lighthouse and git have cropped up which look very intriguing, the lack of automated installation and maintaince and my lack of free time leaves my turning back to my existing trac + svn solution. The integration between these two projects is simply spectacular and the ability to have the software hosted and easily managed on a low cost shared server like DreamHost is definitely a plus.

There was one missing piece after the initial installation process of svn + trac: post commit trac integration. Automatic integration of ticket updates and source code commits usually runs without a problem, but since svn runs under a different user than trac, permission issues arise. The easy solution would be to increase permissions on the trac database file, but this isn’t a very secure solution. The best solution that I have found is to create a proxy file, which holds basic commit information (revision numbers and commit messages), to act as a middleman between trac and svn and then schedule a cron script to pull the logged data and run it through the trac post commit script. Information on how to do this was scattered around the web so I took the time to pull it all together and organize it into one post.

File: ~/trac_projects/project_name/run-post-commit-proxy.bash
Note that this file needs to be run by the same user which handles svn commits (on DreamHost just run this script every five minutes as the user which hosts your svn).

#!/bin/bash

LD_LIBRARY_PATH="/home/user/packages/lib"
PATH="/home/user/packages/bin:$PATH"
PYTHONPATH="/home/user/packages/lib/python2.4/site-packages"

export PYTHONPATH
export PATH
export LD_LIBRARY_PATH

/home/user/trac_projects/project_name/run-queued-trac-post-commits.rb

File: ~/trac_projects/project_name/run-queued-trac-post-commits.rb

#!/usr/bin/ruby

tracDir = '/home/user/trac_projects/project_name'
logFilePath = tracDir + '/queued_commits.txt'
doneFilePath = tracDir + '/queued_post_commits_done.txt'
errorFilePath = tracDir + '/queued_post_commits_errors.txt'
postCommitScriptPath = '/home/user/packages/share/trac/contrib/trac-post-commit-hook'
tracURL = 'http://trac.domain.com/project_name/'
errorEmailTo = 'info@domain.com'

queuedCommits = Array.new
begin
File.open(logFilePath, "r") do |file|
file.each_line do |line|
queuedCommits < < line
end
end
rescue
# no queued commits to process
exit
end

# Empty out the file
system("> #{logFilePath}")

queuedCommits.each do |line|
line.chomp!
repo,rev = line.split(':')
next unless repo and rev

logMessage = `/usr/bin/svnlook log -r #{rev} #{repo}`
author = `/usr/bin/svnlook author -r #{rev} #{repo}`

# to make sure python can fine the trac module
exportCmd = 'export PYTHONPATH="$HOME/packages/lib/python2.4/site-packages/:$PYTHONPATH"'
postCommitCmd = %{/home/user/packages/bin/python  #{postCommitScriptPath} -p "#{tracDir}" -r "#{rev}" -u "#{author}" -m "#{logMessage}" -s "#{tracURL}"}

if system("#{exportCmd}; #{postCommitCmd}")
# log the success
File.open(doneFilePath, "a") do |file|
file.puts("#{Time.now}:#{repo}:#{rev}:#{author}:#{logMessage}")
end
else
# write an error
errorCode = $?
File.open(errorFilePath, "a") do |file|
file.puts("#{Time.now}:#{errorCode}:#{repo}:#{rev}:#{author}:#{logMessage}")
end
# and put the commit info back in the queue file
File.open(logFilePath, "a") do |file|
file.puts line
end
# send an email
system("echo #{errorFilePath} | mail -s 'Post Commit Errors' #{errorEmailTo}")
end
end

File: ~/svn/project_name/hooks/post-commit

#!/bin/sh

REPOS="$1"
REV="$2"

# Just append this info to the log file
echo "$REPOS:$REV" && /home/user/trac_projects/project_name/queued_commits.txt

Some resources I used in putting together the above information:

I stumbled upon an intriguing alternative to Trac: Warehouse. As nice as Trac is, I was never 100% thrilled with its user interface and user management functionality. Warehouse looks to have a beautiful user interface and its user management functionality seems great. It is much closer to a GitHub like interface than most other project management systems I’ve seen lately.

Although svn is a great system, git seems eliminate any frustration still lingering in the svn workflow. Unfortunately I have many build scripts that are built around my svn repositories to it is going to be awhile before I can fully make the transition. However, it seems to be fairly simply to get git up and running on a shared server systemMatt Gemmel posted a nice review of Linode; $20/month for 356MB of ram and 16 HD space doesn’t seem bad at all.

Average Rating: 4.5 out of 5 based on 229 user reviews.

I was away from the PHP world while traveling in Europe and in four short months some nice PHP MVC frameworks seemed to crop up out of nowhere. I’m starting a fairly large project and was determined to use one of these new frameworks as the design and ‘free’ functionality that they offered seemed too good to pass up. However, there was almost too many choices. It was hard to choose between: Cake PHP, Code Igniter, Akelos, PHP Dev Shell, and many others.

For me it ended up coming down to Code Igniter (CI) and Kohana. Kohana is actually a branch off of the CI codebase, keeping with alot of the design choices that make CI attractive, yet stripping the codebase of support for PHP4 and some other legacy technologies and adding support for some of the more advanced PHP5 features. In short Kohana seems like a clean, lean, more ‘modern’ version of CI. I’ve been developing with it for a week and highly recommend checking it out. One of the features I’ve been most impressed by is ORM which uses SQL schema extrapolated from the source database to create a editable object that can perform all CRUD operations. This means only one or two lines of ‘glue code’ to handle the M of the MVC design pattern – Cocoa Bindings for PHP!

The community around Kohana is very impressive for a fairly new PHP framework, I’ve found some very nice addons which have saved me hours of development time:

  • Formo – Easy form creation and validation
  • Message – Easy error/info messages across PHP sessions
  • Head – Dynamic
    head

    creation using PHP

  • s7nCMS – Nice CMS package
  • And much much more

I’ve even posted one of my small extensions.

Average Rating: 4.8 out of 5 based on 196 user reviews.

After almost four years I’ve released the next – and possibly the last for a very long while – version of CSS Optimizer. Aside from minor optimizations, I’ve fixed the last remaining parser bug having to do with “font: 62.5%/1.2em”. I haven’t yet updated the GUI application, but the command line application for linux and os x is updated. I’ve also fixed all issues with the online web css optimizer. Also a little while ago I added a css optimizer web service to allow easier integration to custom automation systems.

I’ve tested CSS Optimizer against some of the newer CSS optimizers such as YUI compressor as well as other online compressors and CSS Optimizer has always come out on top. I’m not one to claim having the “best of” something but I’ve tested many CSS files and CSS Optimizer has always created smaller files and is easy to integrate into any production script/automation system.

Average Rating: 4.4 out of 5 based on 154 user reviews.