Monday, 6. August 2007, 20:20:00
PHP
If you consider how the MVC pattern works in the Zend Framework, it first seems just fine. And yes, it is actually very good, but there's one problem:
It isn't designed to let you access your Models from the ViewsRead more...
Tuesday, 31. July 2007, 22:21:01
web, source code, PHP
I've seen two articles describing how to integrate Smarty with Zend_View,
Integrating Smarty with the Zend Framework at Zend Developer Zone and
Zend Framework: Using Smarty as template engine at Dmytro Shteflyuk's blog. Both of these are
very outdated by now.
So here's take three on integrating Smarty with Zend_View, this time hopefully staying useful for a longer time since the Zend Framework has reached version 1 now.
In this post I will show you a way to integrate Smarty with Zend_View as a new subclass and how to use this class with the new ViewRenderer helper to automatically display templates.
Read more...
Sunday, 15. July 2007, 20:21:53
PHP, programming
If you have done more PHP programming you've probably used a template engine or two. I personally prefer
Smarty as my template engine of choice for most projects.
If you don't know what a template engine is, I'll give a short explanation: Template engine is something that can be used to help separate HTML from PHP - You do all your "business logic" in a PHP file, for example you fetch some things from a database. A template on the other hand is meant to display that data. This is usually achieved by assigning the data to template variables in PHP and then displaying the template file.
But most template engines need setting up and their own code base etc., so for small projects they might add unnecessary complexity and things like that. However,
PHP on its own can be a simple template engine! In this post I'll show you how.
Read more...
Tuesday, 8. May 2007, 12:44:56
PHP, Zend Framework
Yet more Zend Framework -related material.
I've talked with a few people about using Zend_Acl and how to best approach the issue of resources, roles and users.
It isn't immediately obvious how one should do this:
- Create roles and resources in code?
- Load them from a database?
Read more...
Monday, 7. May 2007, 02:47:53
PHP, programming
In this post I'll talk about some of the pros and cons of the MVC (model-view-controller) pattern I've come across, concentrating in the Zend Framework implementation of it.
For those who don't know what the MVC pattern is... It basically is a way of structuring PHP code, data storage and HTML code in separate files. "Model" is the data/data access code, "View" is the HTML code or things such as Smarty templates and "Controller" parses the user requests, fetching information from models, assigning that to views and displaying views etc. For a thorough look, I suggest reading
the Wikipedia article on MVC.
Read more...
Friday, 4. May 2007, 06:43:37
PHP
One of the biggest security holes in PHP has been the Register Globals config variable. It's been
on by default, when it really should be off. They changed it to default to off in PHP 4.2 or something though.
Register globals automatically made variables of all GET, POST, COOKIE etc. variables. So imagine you had some form data you send it with POST. Let's just call it data. That would go in a variable called $data. Now, if someone wanted to cause problems, they could just add ?data=foo to the address bar to add a GET variable called data which might cause $data to be filled with the value from that instead of the form!
Yesterday I saw a bit of code which registered all POST, GET, COOKIE, SESSION and SERVER variables like that. Just like register globals!
Read more...
Monday, 30. April 2007, 01:25:00
PHP
Since I prefer ADODB over Zend Framework's own Zend_DB, I had a small problem: How to use it with Zend_Auth to authenticate the user?
Good thing Zend employs smart people: they use an adapter to control the database access in the Zend_Auth class, called Zend_Auth_Adapter. You can define your own authentication adapter quite easily by creating a class which implements the Zend_Auth_Adapter_Interface interface class.
Let's look at how do you actually do this!
Read more...
Monday, 23. April 2007, 04:36:57
PHP, programming
The
Zend Framework is a framework for building PHP powered web sites, made by Zend - the corporation behind PHP.
It's currently in beta 0.92, but it's very stable and useful nevertheless. Also, it has emphasis on using the MVC pattern when developing sites.
Read more...
Monday, 16. April 2007, 11:18:10
source code, web, PHP
As mentioned in the previous post,
How to improve your blog, in this post I'll demonstrate how to track the visitors of your site with PHP.
You should have some previous knowledge of PHP programming to understand the code and concepts.
Read more...
Wednesday, 31. January 2007, 19:41:14
PHP, web, programming
My latest finished website project,
City-Strike, was a bit different task from what I've usually been doing.
There are some intresting features in the system, like the map and some of the admin tools which obviously you can't test yourself. I also used Smarty and Scriptaculous for the first time ever.
Here are some thoughts about the project and how it turned out and what I think I should've done differently.
Read more...
Showing posts 21 -
30 of 31.