Creating a simple abstract model to reduce boilerplate code

Tags:

In a usual scenario involving models in PHP, you will have some repeating things: You will usually need getters and setters for the model’s properties, you will need to be able to construct the model from an SQL query or such, and you’ll also need to write SQL queries for the models.

While none of this is very complex, it’s something that you need to repeat all the time, and it’s not really something that actually does anything complex. So why not automate at least some of it?

Read More

Ajax, high latency and user experience

Tags:

Most of us probably have used at least one website which bases some major functionality on Ajax. But have you ever used a such site, done something, then moved on to another page, only to come back later to realize what you just did was never saved?

What happens to XMLHttpRequests in a high latency situation, and how to deal with it?

Read More

Closures coming in PHP 5.3 and that’s a Good Thing

Tags:

PHP 5.3 will be introducing closures to PHP. Closures, also known as anonymous functions, will allow you to declare functions “inline” and store them in variables. While the syntax may seem a bit weird compared to how it is in languages like JavaScript, closures will be a useful addition to the language. However, like reflection, it’s a feature that may not immediately show it’s usefulness…

Read More

Zend_Acl part 3: creating and storing dynamic ACLs

Tags:

In this third post of the series, I’ll talk about using dynamic ACLs: How to store an ACL in a database, and construct it from there when needed. This post builds on the things introduced in part 1 and part 2.

We will first look at a simple example with users and pages, and then we’ll have a more complex example, involving building a much more complex ACL with inheritance, role types and other stuff.

Read More

Functional programming and Haskell

Tags:

I’ve been learning some Haskell for fun. Haskell is a functional language, so it’s quite different from other languages I know like PHP or C#.

One of the main “ideas” of functional programming is immutability – in other words, you can’t change the value of a variable after you’ve defined it. How do you deal with this?

Also, Haskell has no loops, like for or while, and a very weird syntax. So is it any good?

Read More

Zend_Acl part 2: different roles and resources, more on access

Tags:

First a quick announcement: please let me know if the blog seems slow/sluggish. I have been experiencing some slowness, and I recently installed WP Super Cache which seems to have helped, but let me know if you encounter anything!

Now, the post: This time, we’ll look at Zend_Acl a bit deeper after the first part

Applications often have different resources: For example, you might have pages, some user generated content like comments, and an admin area. You might also have files, or even real-life objects like a coffee machine.

In the context of Zend_Acl, access to resources is given to roles: A role might be a user’s name, a group a user belongs to, or just roles, which have been assigned to a user from the admin panel.

Since Zend_Acl only defines an “abstract” role, resource and privilege, how do we deal with all of these using it? Read more to find out! I’ll also be addressing some more ways to deal with allowing and denying access.

Read More

Asus Eee PC 901

Tags:

I recently bought myself an Asus Eee PC 901 netbook, with Linux preinstalled. It’s a fine piece of machinery, and here are some thoughts on its hardware, software and how it worked together with my other devices, which are mainly Windows based.

Read More

Zend_Acl part 1: Misconceptions and simple ACLs

Tags:

I’m going to be writing a weekly series of posts on Zend_Acl. This first post will clear up some common misconceptions regarding Zend_Acl, introduce creating ACLs for simple applications, and give some examples on using the ACL in both non-Zend Framework and Zend Framework applications.

Later in the post series I’ll be talking about some more advanced ways of utilizing Zend_Acl, and topics such as database-backed ACLs.

A russian translation of this post is available here, courtesy of Rashad Surkin.

Read More