Cake PHP

Posted by Daniel Lyons Sun, 01 Jul 2007 18:27:00 GMT

Last week I got somewhat acquainted with Cake. I have to admit, any framework is better than no framework, but this framework isn’t a lot better than no framework. I have heard good things about symfony but haven’t given it a shot. If I’m doing PHP, I’d rather be using Voltaire.

Since it’s trying to do for PHP what Rails does for Ruby, it’s probably fair to compare code side-by-side. Ruby:

@users = User.find(:all)

PHP:

$this->set('users', $this->User->findAll());

Hmm. I would have expected that to look more like this:

$users = User::findAll();

And then some view code:

<% for user in @users %>
<tr>
  <td><%= user.name %></td>
</tr>
<% end %>

And in PHP:

<? foreach ($users as $user): ?>
<tr>
  <td><?= $user['User']['name'] ?></td>
</tr>
<? endforeach; ?>

Hmm. I would have expected that to look more like this:

<? foreach ($users as $user): ?>
<tr>
  <td><?= $user->name ?></td>
</tr>
<? endforeach; ?>

Tags , , ,  | 6 comments