Read the latest web development and design tips at Fred Wu's new blog! :-)
Poke me on GitHub

Archive for the ‘PHP’ Category

Zend Framework, where do you want to go tomorrow?

Two weeks ago I started working with Zend Framework at work. I chose to use Zend Framework for one primary reason: Zend. Even though I have plenty of experience with CodeIgniter and Kohana, I simply could not take any risks using them for a rather large project at a company I had just joined.

My experience so far is mixed. Probably because I am so used to the way CodeIgniter and Kohana do things, Zend Framework just appears utterly complicated and difficult to work with (at the beginning).

(more…)

Related posts

Variable methods and accessors in Ruby

Yeah I am a lame PHP guy who hasn’t gotten too deeply into Ruby yet. ;)

In PHP I often use variable methods, for example:

$foo = new Foo();

$funcname = 'dynamic_method';
$foo->$funcname();
// Same as calling $foo->dynamic_method();

$varname = 'dynamic_accessor';
$foo->$varname = 'some value';
// Same as calling $foo->dynamic_accessor = 'some value';

Now, because Ruby does not prefix $ in front of variables, it is impossible to use variable methods the way we do in PHP.

I am sure for Ruby gurus it’s pretty obvious but for me, I just spent more than 30 minutes searching for an alternative other than evil eval, and I finally found one.

We use the PHP call_user_func and call_user_func_array equivalent in Ruby: send or __send__.

Luckily accessors in Ruby are methods, so we are able to use the send method for both methods and accessors.

For example we can set a variable accessor like this:

foo = Foo.new

funcname = 'dynamic_method'
foo.send "#{funcname}"
# same as calling foo.dynamic_method

varname = 'dynamic_accessor'
foo.send "#{varname}=", 'some value'
# same as calling foo.dynamic_accessor = 'some value'

I wish in future versions of Ruby, we can somehow assign accessor values the way we do in PHP. :)

Related posts

Ruby on Rails, Passenger (ModRails) vs CodeIgniter and Kohana

Disclaimer: This is a very simple, ‘Hello World’ benchmark which has no impact to any real world applications. A more thorough benchmark test (by building two real world applications) is planned. :)

Disclaimer 2:I apologise for posting such a useless benchmark (I certainly didn’t expect it to hit the DZone front page), but I think most of you missed the point. I merely posted this as a result of surprise (to me anyway). At a later stage I will conduct a much more meaningful comparison between some of the frameworks. Until then, please ignore this post. :)

Last few days I have been playing with Ruby and Rails, again.

Today, when someone was asking on a forum about the efficiency of web frameworks, I thought I’d give the few frameworks I work with some more benchmark testing.

So I went ahead and benchmarked CodeIgniter, Kohana and Rails, using a simple ‘Hello World!’ page. Now before I post any benchmark results, you should know that I have previously done a benchmark test on CodeIgniter, Kohana and CakePHP. CodeIgniter and Kohana shared similar results.

(more…)

Related posts

Kohana vs CodeIgniter: Speed and Memory Usage Performance Benchmark

This is just a quick and dirty test, please take it with a grain of salt.

We all know that CodeIgniter is a very fast framework, but how about Kohana? Kohana is packed with more features, so does that mean it is slower? Let’s find out.

The following benchmarks are done on my local Macbook Pro machine (C2D 2.4GHz + 4GB), Leopard 10.5.2, MAMP without any code optimisers or caches.

(more…)

Related posts

Zend Framework 1.5 Released

And alongside with the new release, they have revamped their website too.

The website looks better than before, but… oops… that happened when I tried to use the search box:

Zend Framework website error

They have now included a quick start guide which is awesome. For some reason though, I still can’t find a change log on their website.

In my opinion the new website is still horrible to use, the home page is more confusing than ever (huh? why is the roadmap under ‘Give Back’?). I guess the designer didn’t read Steve Krug‘s Don’t Make Me Think. ;)

It feels very ‘Microsoft’y… fingers crossed…

Related posts

Layerful Screencast: Transparent Layer in Action

Okay, so what is a transparent layer? How does it benefit a developer?

Well, please watch the screencast (4min, 12MB) first, you will see the transparent layer in action.

To me, I wanted to make a framework that is more feature-rich than Kohana but at the same time is not intrusive. By having this transparent middle-man layer, a developer is able to seamlessly enhance the Kohana framework without altering the existing user application.

It might not be useful to everyone but what the heck, it at least is useful to one person, me. :D

Related posts