PRADO: PHP goes ASP.NET (ish)

Tags:

Lately, I’ve been checking out PRADO, which is “a component-based and event-driven programming framework for developing Web applications in PHP 5”.

What that actually means is that you can use components, such as a data grid or a button, and work with them based on events without having to think about the traditional things associated with such: Parsing out POST or GET variables and handling the application state.

I think it’s a quite refreshing approach compared to what most PHP frameworks do.

Read More

View inheritance and “blocks” in Zend_View

Tags:

Some frameworks like Django and PRADO have the concept of view inheritance, or a “master page” like in ASP.NET. Essentially it’s a similar idea as Zend_Layout is in Zend Framework, but the difference is that you can define the master/parent view inside the view itself.

For example, in Django {% extends "base.html" %} would make the current template extend “base.html”, and you then you can define blocks that will be placed in placeholder blocks in the parent. In Zend Framework, doing this kind of “blocks” is a bit complicated and it’s a bit difficult to create default content in them as well, which can be optionally replaced with something else.

Since I like the block and inheritance style approach, I decided to see how this can be done in Zend Framework…

Read More

Setting up command-line PHP on Windows

Tags:

On *nix systems you usually have the php executable available in shell, so you can run command-line scripts like unit tests and such, but on Windows this isn’t usually the case. Let’s fix that!

There’s two ways to do this: Temporary and permanent

Read More

Opera UserJS competition

Tags:

Opera recently held a UserJS competition, where I participated with a script that makes Google Spreadsheets work in Opera, a script which improves Apache directory listings and a social bookmarking site toolbar.

Opera chose my Google Spreadsheets script as the winner of Site Fixes category, and I will be receiving a shiny new HTC Touch Diamond phone with Opera 9.5 preinstalled! :D

Head to UserJS contest winners post at myopera to see the other scripts that participated. I think especially History+ is a really cool idea and shows clever thinking and that you can actually do a lot more with UserJS than you might initially think.

On template “tag soup”

Tags:

Jeff Atwood’s latest post (at the time of writing this) talks about mixing HTML markup and server-side code, àla

<table>
 < ?php foreach($foo as $bar): ?>
  <tr>
   <td>< ?php echo $bar; ?></td>
  </tr>
 < ?php endforeach; ?>
</table>

He also throws in the question: Is there a better way? – However, it seems there’s at least as many ideas of a better way as there are programmers…

Read More

Is Smarty really obsolete?

Tags:

There was a short discussion on Zend Framework general mailing list about Smarty being obsolete. I decided to take my opinion here, since the discussion was getting quite off-topic…

Arguments against Smarty presented were mainly the facts that it is PHP4 and its no longer necessary in “modern” web development.

Note: This post was written in 2008.. Although the points are still valid, I would recommend a more modern alternative, such as Dwoo or Twig, instead of Smarty now.

Read More

How to make back, forward and reload work in Ajax-based apps

Tags:

With Ajax apps getting more and more popular, there’s often the question of the browsers own controls working or not in the app in question. If you hit reload, you might end up back on the start page of the application, if you hit back.. who knows.

I think this is especially an issue in applications, where you would work with something, such as files, and you would go between views, like directories, where you might want to go back to the index, previous view or such.

There is a way to do this, at least in some browsers. It’s called location.hash

Read More

Does Google test with just IE and Firefox?

Tags:

Ever tried using Google Spreadsheets with something else than IE or Firefox? Yeah, it doesn’t work very well… Docs used to be the same, but at least something is getting better…

However, the issue in Spreadsheets that stops it from working in Opera 9.5 is ridiculously simple! The JavaScript function which tells you they only support IE and Firefox, and asks if you want to continue never returns the value of the confirmation box, so the result is always the same as clicking cancel.

Is Google purprosefully neglecting testing with other browsers, or was this bug left in intentionally?

PS: If you’re an Opera-user, you can grab my UserJS script that fixes Google Spreadsheets in Opera 9.5

Automating creation and caching of image thumbnails

Tags:

The other day I needed to create some thumbnail images. You know, the usual stuff: Admin uploads image, needs it resized to a smaller one for preview or such…

I thought, why bother with writing code manually in the admin to create the thumbnail? I mean, the requirements for its size might change, the path to thumbnails might change… The whole thumbnail might not even be used after some time!

I say this is a view matter. HTML has always provided the means to define image sizes, but as you hopefully know, sending bigger images than you need is a waste of bandwidth and slows things down unnecessarily.

So what about a class which you could easily use in your view layer to display thumbnails?

Read More