Magento Themes and Magento Extensions

Zend framework coding style standard

Share
Posted on July 12th, 2011 | Posted by admin

Hello again! Today I’ll discuss some of the basic coding rules if your’re using Zend framework (or even Magento, which is written over Zend framework). Some might think that this is an redundant topic, but I strongly disagree – if you work in a team.

Latin introduction

Well, the story about style standards is quite like goes pretty much like old Latin saying “De gustibus non est disputandum” which means “There is no disputing about tastes”. But same things apply to it as well, if you have a big corporate meeting, you won’t go dressed in diving suit, but in a regular one. If you take an parallel look at the coding styles, its pretty much the same. If you’re going to work with a team on new Zend project, some things must be applied. Otherwise you’ll end up in quite a mess.

Memory management in Zend framework

Share
Posted on July 11th, 2011 | Posted by admin

Hello everyone! Recently I’ve noticed that some developers don’t pay much attention to memory management in Zend framework. And here I’m not talking about Zend_Cache, but rather about object sizes. And if you’re thinking that I’m writing nonsenses, let me show you how to reduce memory usage by more than 100 times (in my example :D ).

First of all, I’m going to use PHP’s built in function memory_get_usage() to get difference. Just look at this example, and you’ll know what I’m talking about:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
public static function findById($collectionId,$show_all=false) {
$result = new Application_Model_Collection();
$query_result = $result->queryById($collectionId);
$var1 = memory_get_usage();
//HERE I TOOK MEMORY USAGE BEFORE POPULATING THE RESULT
$result->populateFromQuery($query_result);
$var2 = memory_get_usage();
//AND HERE AGAIN AFTER POPULATING
echo ($var2 - $var1);
//ECHO THE DIFFERENCE IN BYTES
echo ' ';
$clean_result = Application_Model_Collection_Object::parseCollection($result);
return $clean_result;
}

And another snippet:

MySQL transactions in Zend framework

Share
Posted on July 9th, 2011 | Posted by admin

Hi! Today I’m going to explain a part of Zend framework DB functionality. Transactions in general are quite useful, like temporary tables, but in most of situations unnecessary. Because of that, I’m going to explain when and how to use them through Zend framework.

What is transaction?

A simple answer would be – a number of individual queries that are grouped together.

An example would be something like this:

1
2
UPDATE balance SET total = total - 100 WHERE account_id=1;
UPDATE balance SET total = total + 100 WHERE account_id=2;

Zend Framework navigation with breadcrumbs

Share
Posted on June 23rd, 2011 | Posted by admin

It’s been a while since I last time played with beauty of Zend Framework.

Each time I check new features it seems to me that the things are more simplier than the last time,
I might be wrong (I wouldn’t bet on that) or I’m just getting better :)

Let’s check this piece of cake – how you can create navigation with breadcrumbs in Zend Framework project.
As many things in Zend Framework you can get same features in different ways,
so the same thing goes with the Zend_Navigation class.

First of all you need to decide which way you will choose:
- navigation with xml setup file or
- from application.ini file

Working with multiple PHP frameworks – The best practice

Share
Posted on June 20th, 2011 | Posted by admin

Hi, first of all, I’d like to explain the title of this post. I won’t go into depths of complicated examples, but rather explain the logic of it.

PHP first implemented OOP (Object Orientated Programming) the right way in version 5. OOP is powerful tool in any programming language. But the next logic step was to create framework as an “abstract layer” that will help developers in both speed and quality of their work. To conclude this brief introduction, I’ll say that there are many frameworks written in PHP for PHP.:D

Now to the fun part. For example I’ll use Magentos framework, that is written over Zend framework. To make stuff just a little bit more complicated. Zend framework is written on top of PHP’s built in functions.

Page 1 of 212»