Posts

Showing posts from October, 2014

JSON Tutorials : Getting Started

Image
JSON is widely accepted text formatted structured data. JSON stands for "JavaScript Object Notation". In general JSON can represent 1. Object of database record. 2. Object to represent a list of HTML elements. 3. Result of search query. 4. Response of an Ajax call. Here you can see JSON is used in many different areas and for many different scenarios. This means it has simple data structure. most of programming languages adopt it and it can flow easily from one connection to another. You can find JSON office definition here JSON Official Site. JSON is represented by two structural types, which includes two primitive types. Structural types

Array: A sequential list of primitive data types between square brackets [ ]
Object: Collection of key, value pair stored inside curly braces { }, where value would be primitive data type

Primitive types:
There are two primitive types key and value. "key" should be string and "value (data type)" could be anythin…

Doctrine 2 Tutorials: Installation and Configuration

Image
This tutorial post will help you to install Doctrine2 inside your PHP project and configure it so that you can use it's features in plain PHP project.

This post illustrates installation of Doctrine2 using Composer.

Installation First create your project directory


mkdirzainabedcdzainabed
now create composer.json


vicomposer.json
then add following repository information.


{ "require": { "doctrine/orm": "*" } }
Now you are ready to install it via composer, but first we need to install composer into you machine.


curl-sShttps://getcomposer.org/installer|php
Then initiate following command to install Doctrine2


phpcomposer.pharinstall
composer creates "autoload.php" file which helps you to autoload all PHP classes of Doctrine2 ORM project.

Configuration First create configuration file configuration.php for Doctrine2 and include autoload.php inside it.


<?php// configuration.php// Include Composer Autoload require_once"vendor/autol…

Twig Tutorials: Install and Configure

Image
In this tutorial we will see how to install Twig inside your PHP project and then configure it so that we can create use Twig template inside our PHP web application.

later we see a simple Twig template example which will display "Welcome to Twig template" message.

lets see each step one by one.

Install
we can install Twig template via Composer, Git or from PEAR.

in this tutorial post we will install Twig using Composer.

for that we need to create "composer.json" file.

{ "require": { "twig/twig": "1.*" } }
the from console run following command.

  php composer.phar install   

this command will install Twig library.


Configuration
To use Twig template we need configure it first, for that we will create index.php file which will setup Twig autoloader and generate the Twig environment.

using this Twig environment we will render Twig template

include __DIR__ . "/vendor/twig/twig/lib/Twig/Autoloader.php"; //regist…

Generate SSH Public Key for GitHub and Bitbucket

Image
This post demonstrate how to generate SSH private and public key with simple steps and help you to add public key inside your GitHub and Bitbucket account.
But first why we need this SSH public key?
Whenever you access or do some Git operation on remote repository using HTTPS connection from your local machine, you need to authenticate yourself first using username and password.
It looks simple earlier, but later becomes headache.
SSH connection helps us to authenticate using public and private keys, that we generate only once, later we don’t need to authenticate, SSH will do this behalf of us.
But how does it works?
SSH authenticate you using an identity. And this identity is combination of private, public key.
Private Key resides in your local machine and public key inside your GitHub or Bitbucket account.
When you access Git repository, SSH combines these two keys and authenticates you. To use SSH you need to install it first. I assumed that you have already installed it, if not  then please…

Symfony Tutorials: Event Dispatcher

Image
Symfony EventDispatcher is object which interacts with different set of objects when certain event happens.
To illustrate Event Dispatcher definition let’s consider the online shopping website example.
suppose you want to purchase a mobile from online shopping website , but unfortunately that mobile is out of stock.
Then you subscribe into online shopping website for this mobile availability.
When mobile comes in stock, online shopping website notifies you about mobile phone’s availability via email.
In above scenario

you are the Event Listener / Event Subscribermobile availability is Eventonline shopping website is Event Dispatcher.


Symfony EventDispatcher works in same manner.for example, whenever there is HTTP request, Kernel creates a request object and it dispatches an event kernel.request.
Whoever subscribes to kernel.request event gets notified.
So here you might be having few questions in my mind.
What is Event?Event object describe what event is and add some additional information so …