Sunday, May 13, 2012

AMQP Story. Part 1

Introduction

 

Few months ago a friend of mine suggested to do a startup together. I will not tell you yet about the project we’ve decided to do but  I’ll tell you that it is a mobile oriented service. I decided to describe the project flow step by step and so there will be  series of articles and I will do the project presentation in the very last article. So here we go.

Architecture design


I’ve had  some experience in developing back-ends for iPhone apps previously and the main challenge I’ve faced was a sharp rise of load. In other words everybody  started to purchase the app suddenly and the back-end failed to handle such amount of connections. To make things easier to understand I’ll tell you few words about the back-end I used. It was a Zend Framework based application which was working on Apache2 web server, MySQL database was used and the application provided the REST API for the iPhone app. iPhone application was just an image gallery where images were provided by the backend.

Saturday, April 7, 2012

Forms in Zend Framework. Getting rid of routines.

Once I have been asked to write an article to a magazine called phpsolutions. But it appeared that a subscription to this magazine is not free so my article is not available in a public access and could not be shared with a wide range of people and this fact concerns me a lot. As I have no any agreements with the magazine I've decided to publish this article so here it is... 

 

Introduction


Forms and form handling are important parts of the web development. Form handling consists of following stages:
- Form displaying
- Form data filtering
- Form data validation

Zend Framework provides very powerful component for forms handling. In a Zend Framework based application each form has it’s own class where form attributes are set, rules for filtering and validation are described. Please see the Listing 1 for the example

Listing 1. Zend_Form class example
<?php
class forms_ContactForm extends Zend_Form
{
     public function __construct($options = null)
     {
         parent::__construct($options);
         $this->setName('contact_us');
        
         $firstName = new Zend_Form_Element_Text('firstName');
         $firstName->setLabel('First name')
             ->setRequired(true)
             ->addValidator('NotEmpty');
        
         $email = new Zend_Form_Element_Text('email');
         $email->setLabel('Email address')
             ->addFilter('StringToLower')
             ->setRequired(true)
             ->addValidator('NotEmpty', true)
             ->addValidator('EmailAddress');

         $submit = new Zend_Form_Element_Submit('submit');
         $submit->setLabel('Contact us');
         $this->addElements(array($firstName, $email, $submit));
     }
}

So as you can see Zend_Form provides you abilities to manipulate form fields, to filter and validate form data.