Why PHP is So Popular on Web?
If you ever wondered why the hell PHP is so popular on the web when there are better and powerful languages available?
Well, the answer is very simple, It is only language that allows even musicians to build sites for themselves.
By the way that is also the reason why WordPress has become the king of CMS and my choice for starting a WordPress development team – WPoets.
Filed under general | Comment (0)
The Pune effect on Indian Tech Events
Do you know about ‘The Pune Effect’ which influences all the Tech events in India, if not go read.
And if you are an event organiser then consider Pune as venue for your next event.
Filed under general | Comment (0)
Aspiring WordPress Developers Read These Articles First
If you are starting with WordPress Plugin or theme development, or want to know where to start then here is a small list of articles that you should read, some of them should be always open in your browser, and some of them in your RSS reader.
Documentation and Help
1) http://codex.wordpress.org/Function_Reference: This article list almost all the core functions that are available for a plugin developer.
2) http://codex.wordpress.org/Plugin_API/Action_Reference: This article is a complete list of the action hooks available for use in plugin development.
3) http://codex.wordpress.org/Plugin_API/Filter_Reference: This article is a complete list of the filter hooks available for use in plugin development.
4) http://codex.wordpress.org/Data_Validation: This article is list all the function are available in WordPress core to help us with data sanitization and validation
5) http://codex.wordpress.org/Site_Architecture_1.5: This article describes the general site architecture of a WordPress theme to help you understand it.
6) http://wordpress.stackexchange.com: This is *the* place to ask questions related to WordPress development, and off course give answers as well.
7) http://iwebask.com/blog/2011/03/16/75rss-feeds-for-web-developers-wordpress-bloggers/: Whole bunch of links that you should follow on your RSS reader, so that you can stay in sync with latest WordPress tips and tricks.
http://www.w3avenue.com/2009/09/28/definitive-list-of-free-wordpress-theme-frameworks/: This article list whole bunch of theme frameworks that you can use for your themes.
WordPress Core Community
1) http://wpdevel.wordpress.com/ : This is the place where people in the core hang out, read it so that you are upto date with latest happenings about WordPress
2) http://make.wordpress.org/themes/: This is where people who review themes submitted in the wordpress.org theme repository hang out.
Well these are the links that i have found very useful, and I spend most of my time there. If you have any such useful link please share in the comments below.
P.S. We are hiring WordPress developers, email me your resumes if you are interested to become part of the team.
Filed under wordpress | Comment (1)
How To Catch PHP Fatal Error In CodeIgniter
My last few blog post’s are result of the project that I am currently working on, and this blog is also in that series.
We needed to catch PHP Fatal Errors in the production environment and notify about it to developers, also at the same time, showing our beautiful fail whale page to user instead of ugly error or a white screen of death.
Here I will show you how to do this in CodeIgniter, though credit for this idea goes to hipertracker.
First of all you will need to setup a hook, so update your hooks.php file with following code
$hook['pre_system'][] = array(
'class' => 'PHPFatalError',
'function' => 'setHandler',
'filename' => 'PHPFatalError.php',
'filepath' => 'hooks'
);
Now put the code shown below in PHPFatalError.php file in your applications hooks folder.
This is the simplifed version of what I have done, so please update handleShutdown function as per your needs.
Filed under how too? | Comments (2)
Get An Introduction To Functional Programming At TechWeekend 5
5th edition of the TechWeekend is going to be about Functional Programming and if are hearing this term for first time, or if you are like me who has heard about it, but never got time to look into the details then you should definitely attend it.![]()
Event is on 18th Dec 2010, ie this Saturday from 10 AM – 1 PM, at 505, A-Wing, Ground Floor MCCIA Trade Tower( ICC ) on SB Road.
Here is the quick agenda,
- Why you should care about functional programming – by Dhananjay Nene. His id on twitter is @dnene and he currently writes code for and advises Vayana Enterprises in his role as its Chief Architect.
- An Introduction to Erlang – by Bhasker Kode. On twitter he is @bosky101 and he is the CEO and Co-Founder of Pune-based Hover Technologies.
- Clojure & its solution to the Expression Problem – By Baishampayan Ghose. On Twitter he is @ghoseb, and he is the co-founder & CTO of http://Paisa.com
Ohh.. and before I forget you need to register( don’t worry it is free) for the event.
See you guys on Saturday.
Filed under general | Comment (0)
PHP5 patch for FunctionList plugin of Notepad + +
As you may know Notepad++ is my preferred development tool for PHP, and two months back I found FunctionList plugin that shows list of function in a opened PHP file, and it increased my productivity almost immediately.
Only drawback was that it showed just function list and not variables.
And today I found this neat patch of this plugin by Geoffray Warnants which now makes it even better with icons and also showing variable.
Download the patch here (post is in French, scroll down to download the patch)
Filed under how too?, php | Comment (0)
Testing Extjs Application With Selenium : Few Pointers
On a project that I am working on we needed to create few automated tests using selenium. Our frontend is completely written in Extjs.
Being new to testing using selenium, I searched the web and here are few useful advices that I found.
The most comprehensive one was by Ates Goral on stackoverflow.
The biggest hurdle in testing ExtJS with Selenium is that ExtJS doesn’t render standard HTML elements and the Selenium IDE will naively (and rightfully) generate commands targeted at elements that just act as decor — superfluous elements that help ExtJS with the whole desktop-look-and-feel. Here are a few tips and tricks that I’ve gathered while writing automated Selenium test against an ExtJS app.
General Tips
Locating Elements
When generating Selenium test cases by recording user actions with Selenium IDE on Firefox, Selenium will base the recorded actions on the ids of the HTML elements. However, for most clickable elements, ExtJS uses generated ids like “ext-gen-345″ which are likely to change on a subsequent visit to the same page, even if no code changes have been made. After recording user actions for a test, there needs to be a manual effort to go through all such actions that depend on generated ids and to replace them. There are two types of replacements that can be made:
Replacing an Id Locator with a CSS or XPath Locator
CSS locators begin with “css=” and XPath locators begin with “//” (the “xpath=” prefix is optional). CSS locators are less verbose and are easier to read and should be preferred over XPath locators. However, there can be cases where XPath locators need to be used because a CSS locator simply can’t cut it.
Executing JavaScript
Some elements require more than simple mouse/keyboard interactions due to the complex rendering carried out by ExtJS. For example, a Ext.form.CombBox is not really a
<select>element but a text input with a detached drop-down list that’s somewhere at the bottom of the document tree. In order to properly simulate a ComboBox selection, it’s possible to first simulate a click on the drop-down arrow and then to click on the list that appears. However, locating these elements through CSS or XPath locators can be cumbersome. An alternative is to locate the ComoBox component itself and call methods on it to simulate the selection:var combo = Ext.getCmp('genderComboBox'); // returns the ComboBox components combo.setValue('female'); // set the value combo.fireEvent('select'); // because setValue() doesn't trigger the eventIn Selenium the
runScriptcommand can be used to perform the above operation in a more concise form:with (Ext.getCmp('genderComboBox')) { setValue('female'); fireEvent('select'); }Coping with AJAX and Slow Rendering
Selenium has “*AndWait” flavors for all commands for waiting for page loads when a user action results in page transitions or reloads. However, since AJAX fetches don’t involve actual page loads, these commands can’t be used for synchronization. The solution is to make use of visual clues like the presence/absence of an AJAX progress indicator or the appearance of rows in a grid, additional components, links etc. For example:
Command: waitForElementNotPresent Target: css=div:contains('Loading...')Sometimes an element will appear only after a certain amount of time, depending on how fast ExtJS renders components after a user action results in a view change. Instead of using arbitary delays with the
pausecommand, the ideal method is to wait until the element of interest comes within our grasp. For example, to click on an item after waiting for it to appear:Command: waitForElementPresent Target: css=span:contains('Do the funky thing') Command: click Target: css=span:contains('Do the funky thing')Relying on arbitrary pauses is not a good idea since timing differences that result from running the tests in different browsers or on different machines will make the test cases flaky.
Non-clickable Items
Some elements can’t be triggered by the
clickcommand. It’s because the event listener is actually on the container, watching for mouse events on its child elements, that eventually bubble up to the parent. The tab control is one example. To click on the a tab, you have to simulate amouseDownevent at the tab label:Command: mouseDownAt Target: css=.x-tab-strip-text:contains('Options') Value: 0,0Field Validation
Form fields (Ext.form.* components) that have associated regular expressions or vtypes for validation will trigger validation with a certain delay (see the
validationDelayproperty which is set to 250ms by default), after the user enters text or immediately when the field loses focus — or blurs (see thevalidateOnDelayproperty). In order to trigger field validation after issuing the type Selenium command to enter some text inside a field, you have to do either of the following:
- Triggering Delayed Validation ExtJS fires off the validation delay timer when the field receives keyup events. To trigger this timer, simply issue a dummy keyup event (it doesn’t matter which key you use as ExtJS ignores it), followed by a short pause that is longer than the validationDelay:
Command: keyUp Target: someTextArea Value: x Command: pause Target: 500- Triggering Immediate Validation You can inject a blur event into the field to trigger immediate validation:
Command: runScript Target: someComponent.nameTextField.fireEvent("blur")Checking for Validation Results
Following validation, you can check for the presence or absence of an error field:
Command: verifyElementNotPresent Target: //*[@id="nameTextField"]/../*[@class="x-form-invalid-msg" and not(contains(@style, "display: none"))] Command: verifyElementPresent Target: //*[@id="nameTextField"]/../*[@class="x-form-invalid-msg" and not(contains(@style, "display: none"))]Note that the “display: none” check is necessary because once an error field is shown and then it needs to be hidden, ExtJS will simply hide error field instead of entirely removing it from the DOM tree.
Element-specific Tips
Clicking an Ext.form.Button
- Option 1
Command: click Target: css=button:contains('Save') Selects the button by its captionOption 2 Command: click Target: css=#save-options button Selects the button by its idSelecting a Value from an Ext.form.ComboBox
Command: runScript Target: with (Ext.getCmp('genderComboBox')) { setValue('female'); fireEvent('select'); }First sets the value and then explicitly fires the select event in case there are observers.
Second useful tip was about how to continue to run the test when some test fails, it was by Patrick Lightbody
try {
selenium.waitForPageToLoad(timeout);
} catch (e) {
// this will happen after 90 seconds
// todo: recover and send the browser to the the next URL
Another useful tip that I found was by radu that solved the issues caused by auto-generated id by ExtJS.
Selenium tests for ExtJS should rely on CSS selectors.
//table[contains(@class,'seleniumOkButton')]
Finally the most important and useful is the documentation of Testing_Selenium which lists all the supported functions of selenium RC.
One more thing version 0.4.4 of Testing_Selenium pear pacakge has a missing function getNumber check this bug report to get that function.
Filed under general | Comments (4)
Installing PEAR and PHPUnit on WAMP and Windows 7
In the project that i am currently working on, we decided to use PHPUnit for doing our unit testing, and i found that it was not a straight forward thing to install that I had thought it would be. I had to start by installing Pear, and as soon as i type ‘go-pear’ in command prompt and pressed enter key I got my first error.
So here are the steps needed to install PEAR and PHPUnit error free on WAMP.
So let’s start with PEAR, please note my Wampserver is installed on drive ‘H’, substitute it with your own.
Filed under how too?, php | Comments (25)
Simple Way To Add Global Exception Handling In CodeIgniter
I am working on a project where we needed to capture exceptions at a global level instead of doing it at every step as they were not critical, but important for us to know.
The idea was that whenever such an exception occur on production we should send an email to developers mailing list so that someone can investigate it.
As usual I did a quick google search and i found two forum posts in CodeIgniter and one on stackoverflow, but they all fall short as CodeIgniter does not set’s any default exception handlers they way it sets the native error handler.
So here is a quick tutorial on how you can do that.
Continue reading »
Filed under how too?, php | Comments (2)
CodeIgniter 2.0 Is Baking
Just when I was loosing all hopes about CodeIgniter, yesterday EllisLab announced about their move to assembla and mercurial, in that there was a small but significant news about CodeIgniter 2.0.
A quick look into the change log revealed
PHP 4 support is deprecated. Features new to 2.0.0 may not be support PHP 4, and all legacy features will no longer support PHP 4 as of 2.1.0.
This is what I was waiting for. What it means, as pointed by Phil Sturgeon and Elliot Haughin, is that CI 2.0 will not run on PHP 4, but more importantly, it can now take full advantages of PHP 5.
One other thing that I liked is
Added ability to set "Package" paths - specific paths where the Loader and Config classes should try to look first for a requested file. This allows distribution of sub-applications with their own libraries, models, config files, etc. in a single "package" directory.
Which means that now we can create common area where we can keep helpers, views and libraries that needs to be shared between two applications.
While there are many more updates these two got me excited.
For now let’s wait for them to release, meanwhile you can sign up for Bitbucket and follow the updates for CodeIgniter Project.
Filed under general, php | Comments (6)




