Archive

Author Archive

Wordpress to Drupal Migration – Part 1

August 5th, 2010 Zareef Ahmed No comments

Recently I have done few projects where sites were growing rapidly in terms of functionalities and their current wordpress structure was not good enough to handle those changes. I am going to write about the summary of these personal experiences in this series of articles. I will summarize the steps and work I have done to do this migration.

Why Migration?

We should not do something because we can, should only do if need is there. So before starting it is necessary to understand if you really need the migration from Wordpress to Drupal. Wordpress is really a fantastic system and I have used the wordpress on website where we have done big customization and those sites were getting users visit in millions.

Following points can be considered and discussed with the team before finalizing migration :-
1. What is main purpose of migration?
2. What are the main problems which you are supposed to solve with migration?
3. Is there any available way in the current system using which current system issues can be solved?
4. What is the time different between estimation of migration and solving problem within current system?
5. do you see any future benefits in migration?
6. Do you have required skill set and resources to do the migration?
7. Are you migrating because you do not have resources to manage current system?

Gather answers for these questions and then analyze your situation.

In next part I will discuss what benefits Drupal can provide over a Wordpress system?

PHP Interview Questions

June 22nd, 2010 Zareef Ahmed No comments

Hi, I have created a page on my this blog named PHP Interview Questions on which I will compile a list of questions which I normally asks to my candidates. I am not worried about leaking my questions strategy as I know only a good person can handle my supplementary questions I asked on the spot.

What you should know in wordpress to be a wordpress programmer?

February 20th, 2010 Zareef Ahmed No comments

I got several messages that I should point out a list of topics which a developer should know in wordpress to categorize him/her as a wordpress programmer.

“Wordpress Programmer” or “Wordpress Developer” terms can be new to someone but due its popularity, term is getting attention and several companies are doing hiring based on wordpress experience only.

So in this post I am just enlisting some points which a wordpress programmer should know.

  • How to install wordpress? (Yes it really easy but you should know that :) )
  • How to edit config file of wordpress if needed? You should also know what normally can be edited?
  • How to install a plugin in wordpress?
  • How to install a theme in wordpress?
  • How to modify a them in wordpress?
  • What are page templates?
  • How you can create/use a different template for archive or category page?
  • How you can use widgets?
  • How you can create a plugin?
  • How you can modify the content of a post or page?
  • How you can add something before or after a post/page content?
  • What are filters?
  • What are actions and how you can define callback functions on a particular action?
  • How you can create admin menu using plugins?
  • How you can edit the templates in online editor?
  • How you can manage widgets?
  • How you can manage users and thier different types?
  • How you can disable/enable comments on a wordpress site or on a specific page or post?
  • How you can use OPML files?
  • How you can import RSS feeds?
  • How you create custom meta tags in posts?
  • How you can add specific attributes to any post or page?
  • How you can mange user registration?
  • How you can create private blogs or posts?
  • At least 10-15 different plugins which can enhance/extend the basic wordpress functionality.
  • How you can use caching in wordpress?
  • How to upgrade wordpress?
  • How to take backup of wordpress posts using export?
  • How to take database backup of wordpress? (This can be classifieds as normall database backup process)

Above All

You should know what Wordpress CAN not do by default and what we should not try to do with it

Wordpress : A PHP Developer’s delight

January 17th, 2010 Zareef Ahmed No comments

First in the series of my experiments with Open Source CMS, today I will write about my experiments with wordpress as PHP developer.

I heard about wordpress long ago but have used it on large scale since year 2007. I have created some custom setups so different domains can run from same code base. I have also created lots of plugins to handle content customization, displaying different source content like google maps, creating automated posts with different source database, url customizations and lots of things.

I found wordpress very easy to setup, its just few click setup, and in our customization it was just a single click setup for any web site. Creating plugin in very very easy due to its documentation and support for many events and hooks in life cycle of any page.

Different page templates is also one of the great feature of wordpress where you can use different design templates for different pages. I am so impressed with wordpress that I have transferred my this blog to wordpress blog. Wordpress is blessing for PHP developers.

Smarty Sponsorship : Nes Web Design now Sponsors Best PHP Template Engine Smarty

November 30th, 2009 Zareef Ahmed No comments

I am really feeling good by announcing that Nes Web Design (ONS Interactive Solutions Pvt. Ltd.), company with which I am working as CTO is sponsoring Smarty Template Engine, which in my view is the best Template Engine in PHP.Smarty helps a php developer in separating business logic from display logic.

It was year 2003 when I first got a chance to work with Smarty for a big project and today I am still proud of my decision.

Smarty is not just a presentation layer or tool to separate the html from programming code, it is in fact a complete system to handle display logic of your application. Smarty is so good at many things that many people call it a framework instead of template system. It has plug-in capacity,debug tool, programming construct, inbuilt shortcode, ability to extends functions, block level cache and so many other things, even you can use your php code in smarty template if need arise (although it is a bad practice).

Now something about my company Nes Web Design, Nes Web Design is a 9 years old company in the field of Web Design in India and I recently joined Nes Web Design as Chief Technology Officer. We are doing many projects on some industry standards like Zend Framework, Smarty and many more customized solutions.

We will continue our support to the open source movement.

My Experiments with Open Source CMS and E-commerce Solutions

November 5th, 2009 Zareef Ahmed No comments

From now I will write about my experiences with Open Source CMSs/E-commerce Solutions everyday, I have planned to write about my projects and my work in those CMSs as a php developer.

I have planned following CMSs :

1. Joomla
2. Wordpress
3. Drupal
4. SugarCRM
5. OsCommerce
6. Magento
7. PHPbb
8. ZenCart

Of course this list will increase everyday,

Zundoo : Zend CMS : Zend Framework based CMS : A new initiative

September 14th, 2009 Zareef Ahmed No comments

We have just started a new ambitious project Zundoo.

Zundoo is aiming to be a best project for a CMS based on Zend Framwork.

Some of Zundoo’s planned features

1. Easy to Start like Wordpress
2. Extensible like Drupal and Joomla
3. Security above everything
4.Automated update of the core
5. Yes, based on Zend Framework :)
6. Plugin System
7. Theme Based
8. Theme converter for migration from Wordpress or similar types of simple CMS
9. Content importer for different CMS

…………………………… and many more
This will one of the first Zend CMS in the market.

Fear of pain is more painful than pain itself

August 21st, 2009 Zareef Ahmed No comments

I normally don’t write about my personal thoughts and life very frequently due to a simple reason that I am a professional and I am attached to many projects at the same time and I always fear that my personal thought or experience may be bad for my relationship with some of my colleagues or companies I am working with.

As a professional I had made a policy decision that I would resist myself from writing about my personal experiences about my work and projects on my public blogs.

As a professional I had made a policy decision that I would resist myself from writing about my personal experiences about my work and projects on my public blogs.

Although sometime it is really tough to do, especially on the projects when I am being forced to be quite by someone “so called” Boss or senior in the name of keeping good relationship with the client, which eventually don’t happen because no client can compensate a bad work with a good relation. Sometime you need to speak up for the betterment of project. I specially find it more difficult when I think that I may add some value or eradicate something bad in process of project finalization or implementation… and they just forced me to either be quite or just following them blindly.

In last one year I have gone through such experience twice, but …. Wait a second ……I am not going to write about such experiences. (Policy Decision)

My regular readers knows that I normally write about programming and general issues regularly on my different blogs and rarely write about my personals thoughts. Then why I am writing on my personal blog after such a long time?

In last five days I have gone through a specific period of my life when I face different aspects of mysteries of life and pain.

In last five days I have gone through a specific period of my life when I face different aspects of mysteries of life and pain.

I was in Munich city of Germany for a project and as a pure vegetarian (outside my house) I have some restrictions and reservation about food as a normal average Indian like me may have.

I can’t eat the food source of which is not known to me and I can’t eat any pork product so my choices were very limited in Munich. Before reaching Munich it was decided that I am going to use the combination of China and Italian food. (As a matter of fact I like china food a lot and Pizza is the only Italian dish I enjoy), In my view it was a decent choice without any major change in my eating habit or preferences.

(Please don’t start a war about the origin of Pizza, I have very limited knowledge about it’s history but I enjoy it a lot)

But my colleagues who was with me had some other plans and decided to cook at home and he wanted me to be partner of it, reluctantly I agree (I really don’t know how to say a NO).

Keeping story short… everything goes fine but last Sunday evening a pain just grip whole of my stomach after the dinner, initially I thought that it may be some routine thing as I have taken the dinner lately .. I took some digestive pills but they did not work….

I even took the heavy pain killer which I keep with myself for my occasional ear pain…. I tried every trick including prayer to God that please don’t give me this pain as I just have five days to go to home.

BUT nothing worked and it kept increasing with the time…. Just after one and half hour, First time in my life I was on an ambulance and then in the middle of a battery of doctors.

BUT nothing worked and it kept increasing with the time…. Just after one and half hour, First time in my life I was on an ambulance and then in the middle of a battery of doctors.

They did every possible test in short duration of time, they found stones in my bladder but were not able to find any displace stone in my tummy or any infection caused by stones ….. that whole process took more than one hour and during which I was just in pain and nothing else… after that they start experimenting with pain killer … first a mild one … then more dose of it … finally when I beg them to use a stronger one they gave me a good one which bring some peace to my stomach…. I was transferred to a ward and then I was in sleepy mode till morning.

In the morning a new fear came (apart from huge European hospital Bill) what will happen if the pain starts again… Oh No… and it started….. And it was not the pain in my stomach but really was more painful.

My hands were cold even on a thought of pain. Then I realize that fear of pain is more painful than pain itself. My boss suggest that I should immediately come back and I also support the idea … as I was the person who was really feeling the pain… and more importantly project termed was going to finished after four days.

I took the leave of hospital against the advice of doctors; they made me sign some papers which I signed, although I was not able to read anything written on those papers as I don’t know German language. (But fairly enough they provide me a copy of the document which I signed).

………. Then started the great pain period… On the Monday morning I was not feeling pain in my stomach or body but by evening it was in my whole body I even feel pain in my stomach when I breathe…. Unfortunately company was not able to book the ticket to Delhi on the same or next day.

They book it with a gap of one day. I stop eating anything … I just feared that I may be again in the same situation of pain. It was difficult but I spent whole two days just on juice and milk and some biscuits.
On Wednesday morning, I had to rush to Munich airport; I was having my two bags full of my old cloths and accessories weighted more than 25 KG and a handbag with my laptop.

It was difficult and I feared that I may not be able to make it to airport easily.
Then things started improving suddenly… God knows from where I got the strength that I was even able to use stairs to go to platform as escalator was not working on the central station.

Then I pick the train to airport but worst was waiting… after crossing three or four station I realized that I left my handbag at central station…… But magic starts….

I jump from the train at very next station and pick the train back to central station while having my hands full with my other baggage.

God was really taking the tests of my strength on that day … in hurry I use the wrong side of the door to exist from the train and then had to climb and then down the stairs to go to platform where my bag was waiting for me… Thankfully no passenger put the alarm on a not attendant bag.

God was really taking the tests of my strength on that day … in hurry I use the wrong side of the door to exist from the train and then had to climb and then down the stairs to go to platform where my bag was waiting for me… Thankfully no passenger put the alarm on a not attendant bag.

I took the train again to Munich airport only to know that it terminate after some stations and I had to change the train again with my luggage.

Finally I reach the Munich airport… suddenly I realize that no pain was there in breathing… and my body was also not feeling any big pressure.

I resist myself from eating anything on plane to Zurich from where I was to board my connecting flight to Delhi.
After waiting for two hours at Zurich airport finally I board flight to Delhi. As soon as I reach the plane I feel a great sense of relief and suddenly I realize that I was not feeling any pain in my stomach even using a small test punch.

Then I decide to take the plunge… I ate the food provided by them. And Yes…no problem…No pain … I was at ease … the ease of life … ease of being towards home.

So what was the “thing” which I was experiencing since last two days specially after leaving the hospital against doctor’s advice?
If it was a medical problem how it disappear without any medicine or treatment and if it was not then how I have gone through such acute and unbearable pain? Doctors were able to find some stones in my stomach so I can’t rule out a medical problem.
Then I decide to write about it… and I found out that I was really suffering from a medical problem named “fear of pain”. It is a medical problem

http://www.medterms.com/script/main/art.asp?articlekey=12283

After the first stroke of pain after my dinner on Sunday, I was feared that if this pain increases it may ruin my whole trip… that was the point when things started going out of control… That was the point when I lost the control from my body and I was totally controlled by “Fear of Pain” instead of pain itself.
For the next two days I was suffering from the “algophobia” as doctors termed it.

As soon as I was coming closer to my home I was getting the feeling that pain is not a big deal… I can just take a pain killer injection and everything will be fine in few minutes as doctors in India are different from doctors of Germany, My insurance was going to work in my country and even fear of a huge bill was not there… so the fear of pain was just not there and I was healthy.

AS I am writing these lines I am feeling perfectly fine, had taken a good meal in the evening, drove my car for more than 150 km on the highway with my wife and children and YES everything is fine.

People who fear pain are more likely to suffer it

Does Algophobia Bother You?

PHP Functions to work with PHP functions

July 9th, 2009 Zareef Ahmed No comments

In this article, I am going to write about the functions using which you can get the information about php functions.

For a full list of PHP functions you can visit http://www.zend.com/phpfunc/

Using these functions you can query the stats/status of your functions, these functions are very useful in dynamic application creation.

For example, using func_get_arg and func_num_args functions you can simulate the function overloading in PHP.

Read a good example for http://www.dubi.org/php-function-overloading

Functions I will write in this article are :-

get_defined_functions();

You want to how many functions are in your installation of PHP, just call this function, it will return an array of all php functions you can call. For the convince it return an multidimensional array, so you can access both internal and user defined functions separately.

func_get_arg()

Returns the argument which is at the arg_num’th offset into a user-defined function’s argument list. Function arguments are counted starting from zero. func_get_arg() will generate a warning if called from outside of a function definition. This function cannot be used directly as a function parameter. Instead, its result may be assigned to a variable, which can then be passed to the function.
If arg_num is greater than the number of arguments actually passed, a warning will be generated and func_get_arg() will return FALSE.
As this function depends on the current scope to determine parameter details, it cannot be used as a function parameter. If you must pass this value, assign the results to a variable, and pass the variable.

func_get_args()

Returns an array in which each element is a copy of the corresponding member of the current user-defined function’s argument list. func_get_args() will generate a warning if called from outside of a function definition. This function cannot be used directly as a function parameter. Instead, its result may be assigned to a variable, which can then be passed to the function.
This function returns a copy of the passed arguments only, and does not account for default (non-passed) arguments.
As this function depends on the current scope to determine parameter details, it cannot be used as a function parameter. If you must pass this value, assign the results to a variable, and pass the variable.

func_num_args() Returns the number of arguments passed into the current user-defined function. func_num_args() will generate a warning if called from outside of a user-defined function. This function cannot be used directly as a function parameter. Instead, its result may be assigned to a variable, which can then be passed to the function.
As func_get_arg() this function also can not be passed as argument to another function.

function_exists()

Checks the list of defined functions, both built-in (internal) and user-defined, for function_name. Returns TRUE on success or FALSE on failure.

create_function()

Creates an anonymous function from the parameters passed, and returns a unique name for it. Usually the args will be passed as a single quote delimited string, and this is also recommended for the code. The reason for using single quoted strings, is to protect the variable names from parsing, otherwise, if you use double quotes there will be a need to escape the variable names, e.g. \$avar.

This is one of very useful function to create dynamic application, using this function you can create the function at run time and then use them as per your requirements.

call_user_func()

Call a user defined function given by the function parameter.
People are divided on the use of this function, some thinks that it is not needed at all when we can run the function on the variable itself.
Like use of this function is

function test($value)
{
print "This is $value";
}

call_user_func("test","test value");

some people prefer using variable function like this :-

$funcname="test";
$funcname("test");

This is also a call_usr_func_array function.

is_callable()

If you are going to use a a variable function like previous example, you may need to verify if a function already present and callable? using this function you can do that.
This function Verify that the contents of a variable can be called as a function. This can check that a simple variable contains the name of a valid function, or that an array contains a properly encoded object and function name.
The var parameter can be either the name of a function stored in a string variable, or an object and the name of a method within the object, like this:

array($SomeObject, 'MethodName')

In some way it is similar to function_exisits function but it does more that that if you just want to check the syntax then you can pass a second argument as True, in that case it only verifies that var might be a function or method. It will only reject simple variables that are not strings, or an array that does not have a valid structure to be used as a callback. The valid ones are supposed to have only 2 entries, the first of which is an object or a string, and the second a string.

PHP is a functional language and you can almost do anything with these functions.

Tags:

PHP Training Education Tutor in Delhi NCR

June 22nd, 2008 Zareef Ahmed No comments

As PHP is gaining the ground in India, numbers of initial level jobs are also increasing day by day. Almost every day I got questions from new comers how they can learn PHP? Which training institute is providing the training in PHP?

Unfortunately almost all major player of training industry in India, specially Delhi are still not doing much (I should nothing) in this regard.

So I am thinking about organizing PHP training camps in and around Delhi in this summer, If you would like to be in that camp, I would request you for sending a message via my contact us page.

Please give me some details about yourself and in which area of Delhi or NCR you will prefer the camp.


Click here to send your message for PHP training camp.

Tags:

Use Exit after redirecting user via header function

June 18th, 2008 Zareef Ahmed No comments

Some weeks ago I got an old PHP application to work with. I was asked to look for the potential problems and bottlenecks in the application. So I decide to use APD as a profiler for the application, after installing the APD on that server. I enabled profiler on one of the reportedly slow page.

That page was meant to be displayed and executed only if user is logged in and session variables are set. If we don’t found user session then user was being redirected to Login page of the application.

I called that page directly in the browser and got the login screen. It was perfectly acceptable behavior.

BUT when I run the profiler to get the information about the execution of page I was surprised to see that almost all functions which were only meant to be executed for logged in users were being called and they were taking the system resources.

Just to confirm I refresh the page in browser many time (without login), and each time I got same profile information for page.

Then I run the test using Apache benchmark (ab) and while test was in running I decide to see the process list of mysql database, again I see that heavy queries were being fired on the database. (But this time I was not surprised, as it was expected and I did just to confirm and take the screen shot so I can show that to the owner of the application.)

Now I decide to check the reason behind this, so I opened that page in my Zend Studio, and yes I got the reason …

Application was redirecting the user to login page if user is not logged in using header function via location define mechanism Like

  header("location: login.php");

And they were not using exit after that. I just add the exit(); after that header function call and problem was fixed.

header("location: login.php");
exit();

Just an improper use of header was the reason behind unnecessary load on the web server as well as on database server.

Note : If you do use the location setting of the header to redirect to another page, do not forget to use “exit;” to prevent further execution of script code.

Tags: